From ce740529fede5f1267d874540bb3de312533b777 Mon Sep 17 00:00:00 2001 From: Peter Hoffmann <954078+p-hoffmann@users.noreply.github.com> Date: Mon, 25 Aug 2025 20:39:25 +0800 Subject: [PATCH 1/2] Implement error handling in console logging --- ext/runtime/js/bootstrap.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/runtime/js/bootstrap.js b/ext/runtime/js/bootstrap.js index 0fa5fcf5..96b197d2 100644 --- a/ext/runtime/js/bootstrap.js +++ b/ext/runtime/js/bootstrap.js @@ -643,7 +643,12 @@ globalThis.bootstrapSBEdge = (opts, ctx) => { ObjectDefineProperties(globalThis, { console: nonEnumerable( new console.Console((msg, level) => { - return ops.op_user_worker_log(msg, level > 1); + try { + return ops.op_user_worker_log(msg, level > 1); + } catch (error) { + console.error(`Failed to log message: ${error.message}\n${level}: ${msg}`); + return; + } }), ), }); From fbaecec5bb45ada611f7a5f2ce377a9f99f1d792 Mon Sep 17 00:00:00 2001 From: Peter Hoffmann <954078+p-hoffmann@users.noreply.github.com> Date: Tue, 26 Aug 2025 15:14:43 +0800 Subject: [PATCH 2/2] Change console.error to globalThis.console.error --- ext/runtime/js/bootstrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/runtime/js/bootstrap.js b/ext/runtime/js/bootstrap.js index 96b197d2..2e9f64ef 100644 --- a/ext/runtime/js/bootstrap.js +++ b/ext/runtime/js/bootstrap.js @@ -646,7 +646,7 @@ globalThis.bootstrapSBEdge = (opts, ctx) => { try { return ops.op_user_worker_log(msg, level > 1); } catch (error) { - console.error(`Failed to log message: ${error.message}\n${level}: ${msg}`); + globalThis.console.error(`Failed to log message: ${error.message}\n${level}: ${msg}`); return; } }),