From 43d067396b5a620441b9a299c45e7b0b129ccd15 Mon Sep 17 00:00:00 2001 From: Agando Date: Thu, 29 Oct 2026 12:13:33 +0100 Subject: fix(newos4): js console handles promise rejections + Node-builtin hint (v4.6.128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit evalJS() evaluated the expression bare and printed JSON.stringify(result), so a rejected thenable (e.g. `js import('fs')`) became `{}` on screen while the rejection escaped to window.onunhandledrejection and was auto-filed as a runtime bug report (RPT-20261028-172211-9c7f2adb, cluster 480x). evalJSFile() already had .then/.catch — the asymmetry was the defect. - modules/ext/console.js: thenable branch in evalJS() awaits and catches; new _printError() is the single error sink for all four catch paths and appends a hint when a bare specifier fails to resolve ("'fs' is a Node built-in; the browser has no Node — use the VFS (ls/cat/run, terminal.fs) instead"). - help.html: js / js-run rows say "browser only — no Node built-ins". - module-loader.js + main.html: v4.6.128. Verification (/tmp/test-console-fs.js, 11 asserts, new Function harness over the module): GREEN 11/11 — rejection prints one red error + hint, no unhandledRejection; resolved thenable prints its value; sync value/throw unchanged; js-run file + missing file OK. RED 4/11 against .bkp-console-20261029_121243/console.js — A1/A2/A3 print `{}`, A4/G2 leak "Failed to resolve module specifier 'fs'". node --check modules/ext/console.js → OK. console.js is loaded separately via extKeys (not in critical-ext-bundle.js), so no bundle rebuild — proven by `grep -c JSConsoleModule modules/ext/critical-ext-bundle.js` = 0. Consumes STEER-20261028-195043-8084. Plan: .hermes/plans/2026-10-29_063000-newos4-js-console-fs-specifier.md --- help.html | 4 ++-- main.html | 6 +++--- modules/core/module-loader.js | 2 +- modules/ext/console.js | 35 +++++++++++++++++++++++++++++++---- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/help.html b/help.html index b812fcd..185a9da 100644 --- a/help.html +++ b/help.html @@ -1007,8 +1007,8 @@ ollamaconnect listmodsList all loaded modules load-localLoad module from VFS or URL loadlocalAlias for load-local - js <expr>Evaluate JavaScript in page context - js-run <path>Load and execute a JS file from VFS + js <expr>Evaluate JavaScript in page context (browser only — no Node built-ins such as fs) + js-run <path>Load and execute a JS file from VFS (browser only — no Node built-ins) startup-modulesConfigure boot modules module-load <name>Load a module by name module-unload <name>Unload a module diff --git a/main.html b/main.html index c386cc2..60ab3f0 100644 --- a/main.html +++ b/main.html @@ -1349,13 +1349,13 @@ - + - + - +