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 |
a949698 to
ff79eed
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
dario-piotrowicz
left a comment
There was a problem hiding this comment.
I haven't touched this code in quite and the changes here are quite significat, but generally the changes do look good to me
I also spot checked a few test files and everything there seems to generally make sense to me
I think this PR should definitely also get some other reviews besides mine before landing, in particular if @BridgeAR could have a look that'd be great I think 🫶
Signed-off-by: Aviv Keller <me@aviv.sh>
6b050ce to
4312021
Compare
|
IIRC semver-major requires at least 2 TSC approvals, so cc @nodejs/TSC |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #64034 +/- ##
==========================================
- Coverage 90.23% 90.14% -0.09%
==========================================
Files 741 741
Lines 241604 241917 +313
Branches 45520 45535 +15
==========================================
+ Hits 218010 218082 +72
- Misses 15120 15348 +228
- Partials 8474 8487 +13
🚀 New features to boost your workflow:
|
**Description:** Adds an independent Rust/WebAssembly binding at `bindings/binding_nodejs_support_wasm`, published as `@swc/nodejs-support-wasm`. The package has its own Rust crate, sources, build scripts, tests, README, Cargo entry, and npm workspace entry. It does not build from `binding_typescript_wasm` and does not add features or exports to the existing `@swc/wasm-typescript` or `@swc/wasm-typescript-esm` packages. The new CommonJS package embeds its wasm binary and exposes these APIs at the top level: - `transform` - `transformSync` - `transformModuleSyntax` - `getFirstExpression` - `isValidSyntax` - `isRecoverableError` It also exports the related `Options`, `TransformOutput`, and `ModuleSyntaxTransformOutput` TypeScript types. The npm publish matrix, wasm CI matrix, release versioning, Cargo lockfile, and pnpm lockfile now reference the standalone `binding_nodejs_support_wasm` crate. Validation performed: - `git submodule update --init --recursive` - `cargo fmt --all -- --check` - `cargo test -p binding_typescript_wasm -p binding_nodejs_support_wasm` - `cargo clippy --all --all-targets -- -D warnings` - `(cd bindings/binding_nodejs_support_wasm && ./scripts/test.sh)` - `(cd bindings/binding_typescript_wasm && ./scripts/test.sh)` - `(cd bindings/binding_core_wasm && ./scripts/test.sh)` - `(cd bindings/binding_minifier_wasm && ./scripts/test.sh)` - `(cd bindings/binding_es_ast_viewer && ./scripts/test.sh)` - `(cd bindings/binding_nodejs_support_wasm/pkg && npm pack --dry-run --json)` - `pnpm install --frozen-lockfile --ignore-scripts` - `go run github.com/rhysd/actionlint/cmd/actionlint@latest .github/workflows/CI.yml .github/workflows/publish-npm-package.yml` **BREAKING CHANGE:** None. The existing TypeScript wasm packages and their public APIs are unchanged. **Related issue (if exists):** - Supports nodejs/node#64034 - Follow-up context from #11973
|
Bump! |
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.