Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
suppress console.error while creating InferenceSession
  • Loading branch information
nico-martin committed Nov 30, 2025
commit 1300ab0b9c107843fff0bae10ee3972c3f9460a8
17 changes: 13 additions & 4 deletions src/backends/onnx.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,19 @@ let webInitChain = Promise.resolve();
* @returns {Promise<import('onnxruntime-common').InferenceSession & { config: Object}>} The ONNX inference session.
*/
export async function createInferenceSession(buffer_or_path, session_options, session_config) {
const load = () => InferenceSession.create(buffer_or_path, session_options);
const session = await (IS_WEB_ENV ? (webInitChain = webInitChain.then(load)) : load());
session.config = session_config;
return session;
// Temporarily suppress console.error from WASM module warnings
const originalConsoleError = console.error;
console.error = () => {};

try {
const load = () => InferenceSession.create(buffer_or_path, session_options);
const session = await (IS_WEB_ENV ? (webInitChain = webInitChain.then(load)) : load());
session.config = session_config;
return session;
} finally {
// Restore console.error
console.error = originalConsoleError;
}
}

/**
Expand Down
Loading