repl: use inspector over vm#64034
Conversation
|
Review requested:
|
9fdad96 to
56ebb41
Compare
3f34721 to
d7534b9
Compare
|
cc @nodejs/repl @nodejs/inspector |
|
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
012ec64 to
e428a2e
Compare
33e1f17 to
a949698
Compare
|
Does this change make tab-completions side-effect free in all cases? await $`echo hello`.sometextwas printing hello whilst tab completing. |
|
Hi @qwitwa! Unfortunately, that specific case is not resolved by this PR. Although, that might be an issue with V8, since the REPL relies on CDP's |
|
Bump @nodejs/repl @nodejs/vm @nodejs/inspector |
Signed-off-by: Aviv Keller <me@aviv.sh>
a949698 to
ff79eed
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
|
@qwitwa I've re-written the completion logic to benefit from the same inspector changes as the rest of this PR, including better side effect detection. I believe the issue stemmed from the fact that our completion was not relying fully on CDP's side effect detection, and instead some custom side effect detection logic in cases of unique objects (e.g. getters, proxies). The latest changes to this PR should resolve your issue, and allow for completions in more side-effect free cases. |
This PR switches the REPL from
node:vmtonode:inspector, moving it from a synchronous to an asynchronous evaluator. This brings the following improvements:awaitis now natively supported by the inspector, so--no-experimental-repl-awaitis no longer accepted. This also resolves a known limitation where TLA would invalidate the lexical scoping ofconstdeclarations.import ... from '...'are now transformed into real dynamic imports and executed, rather than throwingCannot use import statement outside a modulewith a hint to rewrite the import manually. This isn't strictly required by removingnode:vm, but the change makes it easier. I can split this into a separate PR if preferred.node:vmissues are resolved (see the list below), and users can now attach process listeners without breaking the REPL..load-ed file where an error was thrown.This is a semver-major change; see the reasons listed in the notable changes section.
Removed Tests
addons/repl-domain-abort,parallel/test-repl-domain.js: We no longer rely on thedomainmodule, so testing it is no longer needed.parallel/test-repl-no-terminal-restore-process-listeners.js: An extension of the above — we no longer modify the ability to set process listeners.parallel/test-repl-uncaught-exception-async.js/parallel/test-repl-uncaught-exception.js/parallel/test-repl-tab-complete-nested-repls.js: An extension of the above; this test case no longer throws an error.known_issues/test-repl-require-context.js: This known issue has been resolved.parallel/test-repl-top-level-await.js: No need to test TLA — it's supported natively by the inspector.parallel/test-repl-preprocess-top-level-await.js: An extension of the above; the REPL no longer pre-processes top-level await.parallel/test-repl-preview-without-inspector.js: The REPL no longer works without the inspector.parallel/test-util-sigint-watchdog.js: This tested code that has been removed as part of this migration.pseudo-tty/repl-dumb-tty.js: There's currently no way to conditionally run these tests (run only when inspector is available).Fixes: #61390
Fixes: #63126
Fixes: #38503
Fixes: #39387 (Closes #39392)
Fixes: #37445
Fixes: #38145
Fixes: #33369
Fixes: #48131
Fixes: #8309
Fixes: #39689
Fixes: #18931
Notable Change
The REPL has been re-implemented on top of the V8 Inspector (
node:inspector) rather thannode:vm. This moves the REPL from a synchronous to an asynchronous evaluator and resolves long-standing design quirks that stemmed from thevm-based design:await, the--no-experimental-repl-awaitflag is no longer accepted, and top-levelawaitno longer corrupts the lexical scoping ofconst/letdeclarations. Additionally, statements that would normally return aPromiseare now awaited until they settle.import { readFile } from 'node:fs/promises'are now transformed into real dynamic imports and executed._and_errorare available even in REPLs with a modified context.uncaughtException) without disrupting evaluation.queueMicrotask/timer callbacks, andvmasync timeouts, no longer take down the process.Breaking changes
In addition to the removal of
--no-experimental-repl-awaitand similarawaitchanges noted above:SyntaxErroris no longer emitted in the main REPL; this information is still available programmatically in the stack trace.