Repository navigation
fix(runtime): bridge console to the inspector regardless of --inspect flag - #35795
Conversation
… flag The main-worker bootstrap wrapped the console into the V8 inspector console only when an --inspect* flag was present at startup. When the inspector is activated later at runtime - via node:inspector open() (as the vscode-js-debug bootloader does) or SIGUSR1 - Runtime.consoleAPICalled is never emitted, so debugger clients (e.g. the VS Code Debug Console) show no console output even though the session is otherwise fully functional. The worker bootstrap already wraps unconditionally; do the same for the main worker. The bootstrap options slot (3) is left in place, only its consumer is removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Spec test for the previous commit: a --require preload opens the inspector at runtime, the test connects a CDP session, enables the Runtime domain and asserts consoleAPICalled events arrive for console.log calls. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tor_test.ts Match fd6fc7a from denoland#35796: drop the hand-rolled spec test in favor of a unit test next to the other inspector protocol tests, reusing the extractWsUrl helper and cleaning up the child process in a finally block. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…f hanging Race the wait against a 10s deadline (the child logs every 100ms) and clear the timer in the teardown block. Verified both paths: passes in ~215ms, and with the fixture silenced fails at 10s with a diagnostic. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The failing (The one Root cause: This is exactly what Node hits, and they solve it by restoring the name right after binding ( consoleFromNode[key] = FunctionPrototypeBind(
consoleCall,
consoleFromNode,
consoleFromVM[key],
consoleFromNode[key],
);
ObjectDefineProperty(consoleFromNode[key], 'name', {
__proto__: null,
value: key,
});deno_core's The fix belongs upstream in deno_core's customConsole[key] = FunctionPrototypeBind(
callConsole,
customConsole,
consoleFromV8[key],
customConsole[key],
);
ObjectDefineProperty(customConsole[key], "name", {
__proto__: null,
value: key,
});Once deno_core carries that, the worker bootstrap (which already wraps unconditionally) and this change will both keep the correct method names. |
…Console core.wrapConsole binds each console method to callConsole, which clobbers its .name to "bound callConsole" and, because callConsole was constructable, made `new console.log()` succeed. With the main worker now wrapping the console unconditionally this broke node_compat's test-console-methods.js. Match Node's wrapConsole: restore the original method name after binding (ObjectDefineProperty) and create callConsole with ConstructorBehavior::Throw like Node's consoleCall, so bound methods throw when invoked with `new`.
|
Thanks for the diagnosis - fixed in 4b82407. Since deno_core lives in this repo now (
The second change is needed because the CI run only ever hit the Verified locally: |
… flag (#35795) The main-worker bootstrap wrapped the console into the V8 inspector console only when an `--inspect*` flag was present at startup. When the inspector is activated later at runtime - via `node:inspector` `open()` (as the vscode-js-debug bootloader does) or SIGUSR1 - `Runtime.consoleAPICalled` is never emitted, so debugger clients (e.g. the VS Code Debug Console) show no console output even though the session is otherwise fully functional. The worker bootstrap already wraps unconditionally; do the same for the main worker. The bootstrap options slot (3) is left in place, only its consumer is removed. Includes a regression test (`inspector_console_api_late_open` in `tests/unit/inspector_test.ts`, next to the other CDP protocol tests): it spawns a child that opens the inspector via a `--require` preload, connects over CDP, and asserts `Runtime.consoleAPICalled` arrives for `console.log`. The wait is bounded by a 10 s deadline so a regression fails with a diagnostic instead of hanging, and the child is killed in a `finally` block. Part of a series fixing VS Code debugging with `--watch` (#35791). --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The main-worker bootstrap wrapped the console into the V8 inspector console only when an
--inspect*flag was present at startup. When the inspector is activated later at runtime - vianode:inspectoropen()(as the vscode-js-debug bootloader does) or SIGUSR1 -Runtime.consoleAPICalledis never emitted, so debugger clients (e.g. the VS Code Debug Console) show no console output even though the session is otherwise fully functional.The worker bootstrap already wraps unconditionally; do the same for the main worker. The bootstrap options slot (3) is left in place, only its consumer is removed.
Includes a regression test (
inspector_console_api_late_openintests/unit/inspector_test.ts, next to the other CDP protocol tests): it spawns a child that opens the inspector via a--requirepreload, connects over CDP, and assertsRuntime.consoleAPICalledarrives forconsole.log. The wait is bounded by a 10 s deadline so a regression fails with a diagnostic instead of hanging, and the child is killed in afinallyblock.Part of a series fixing VS Code debugging with
--watch(#35791).