Skip to content

repl: use inspector over vm#64034

Open
avivkeller wants to merge 4 commits into
nodejs:mainfrom
avivkeller:repl-inspector
Open

repl: use inspector over vm#64034
avivkeller wants to merge 4 commits into
nodejs:mainfrom
avivkeller:repl-inspector

Conversation

@avivkeller

@avivkeller avivkeller commented Jun 20, 2026

Copy link
Copy Markdown
Member

This PR switches the REPL from node:vm to node:inspector, moving it from a
synchronous evaluator to an asynchronous one. This includes the following improvements:

  1. --no-experimental-repl-await is no longer allowed, top-level await
    is no longer experimental and is natively supported by the inspector. This
    also resolves a known limitation in which TLA would invalidate the lexical
    scoping of const declarations.
  2. **Static imports such as import ... from '...' are now transformed into real
    dynamic imports and executed, instead of throwing
    Cannot use import statement outside a module with a hint to rewrite the
    import manually. This is not strictly required by removing node:vm, but it
    is made easier by the change. I can split this into a separate PR if
    preferred.
  3. Several node:vm issues are resolved (see the list below), and users
    can now attach process listeners without breaking the REPL.
  4. Errors are more detailed, for instance, showing the specific line in a
    .load-ed file where an error was thrown.

This is a semver-major change:

  • --no-experimental-repl-await is no longer accepted.
  • Stack traces may have slightly different output (errors are more detailed).
  • SyntaxErrors no longer show the exact offset of a given error.

Fixes: #61390
Fixes: #36047
Fixes: #38503
Fixes: #39387 (Closes #39392)
Fixes: #37445
Fixes: #38145
Fixes: #33369
Fixes: #48131
Fixes: #8309
Fixes: #39689

Closes #63879


Notable Change

The REPL has been re-implemented on top of the V8 Inspector (node:inspector)
rather than node:vm. This moves the REPL from a synchronous evaluator to an
asynchronous one and resolves a long-standing design quirks that stemmed from the vm-based design:

  • Because the inspector natively
    supports top-level await, the --no-experimental-repl-await flag is no
    longer accepted, and top-level await no longer corrupts the lexical scoping of
    const/let declarations.
  • Lines such as
    import { readFile } from 'node:fs/promises' are now transformed into real dynamic imports and executed.
  • _ and _error are available even in REPLs with a modified context.
  • Users can now
    add listeners (e.g. uncaughtException) without disrupting evaluation.
  • Throwing inside queueMicrotask/timer callbacks, and vm async timeouts, no longer take down the process.
  • And more

Breaking changes

In addition to the removal of
--no-experimental-repl-await noted above:

  • Because errors now surface through the
    inspector, their output (including added detail) can differ from previous
    releases. Code or tests that match on exact REPL error/stack-trace text may
    need to be updated.
  • The caret/offset indicator that pointed at the precise location of a SyntaxError is no longer emitted in the main REPL, however, this information is still available programmatically in the stack trace.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config

@avivkeller avivkeller marked this pull request as draft June 20, 2026 21:46
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jun 20, 2026
@addaleax addaleax added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 20, 2026
@avivkeller avivkeller added the repl Issues and PRs related to the REPL subsystem. label Jun 20, 2026
@avivkeller avivkeller force-pushed the repl-inspector branch 4 times, most recently from 9fdad96 to 56ebb41 Compare June 21, 2026 23:58
@avivkeller avivkeller changed the title [WIP] repl: use inspector over vm repl: use inspector over vm Jun 22, 2026
@avivkeller avivkeller marked this pull request as ready for review June 22, 2026 00:03
Signed-off-by: Aviv Keller <me@aviv.sh>
@avivkeller

Copy link
Copy Markdown
Member Author

cc @nodejs/repl @nodejs/inspector

@avivkeller avivkeller added the notable-change PRs with changes that should be highlighted in changelogs. label Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @avivkeller.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. repl Issues and PRs related to the REPL subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

3 participants