Skip to content

node: repl v26 compat fixes (+6 tests) - #35530

Draft
cirospaciari wants to merge 10 commits into
claude/node-repl-v26bfrom
claude/node-repl-v26-wave2
Draft

cirospaciari wants to merge 10 commits into
claude/node-repl-v26bfrom
claude/node-repl-v26-wave2

Conversation

@cirospaciari

@cirospaciari cirospaciari commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Stacked on claude/node-repl-v26b (#35388) → claude/repl-tab-complete-unary (#34642) → ciro/repl-node-tests (#31827).

What this does

Implements REPL inline previews, let/const tab completion, and Node-shaped REPL require() errors, plus a deleted-cwd startup fix and a process.config spelling fix. Vendors 6 more upstream Node v26.3.0 tests that now pass verbatim.

Changes

1. REPL previews: emulate the V8 inspector session (src/js/internal/repl/node-shims.js, src/js/node/repl.js)

Node's previews post Runtime.evaluate {throwOnSideEffect: true} on an inspector session; our shim's sendInspectorCommand unconditionally called onError(), so setupPreview never produced output (this was the open FINDING from the last wave). JSC has no side-effect-checking evaluator, so the shim now implements the session itself:

  • expressions are vetted statically first (acorn AST allowlist, fail-closed: assignments, top-level declarations, delete, and calls outside an allowlist of known-pure callees are rejected without evaluating; mutating methods like .fill() are allowed only on receivers the expression itself allocates, mirroring V8's "temporary object" rule);
  • vetted expressions run in the REPL's vm context (displayErrors: false; no timeout — JSC's Watchdog asserts on the REPL's re-entrant use, and the vet already rejects unbounded top-level constructs);
  • results come back as V8-shaped RemoteObjects (value / unserializableValue / opaque objectId), and Runtime.callFunctionOn runs the inspect callback in the same context. Callbacks fire synchronously — utils.js's double-eval of {-wrapped input depends on it.
  • repl.js gains one adapted line: after vm.createContext(), session.contextCreated(context) echoes the Runtime.executionContextCreated event JSC's inspector cannot observe. The context object itself is the opaque context id.

Known deviation (commented in the file): the vet goes by callee name/shape, so a user binding shadowing an allowlisted name (Array = f) can be invoked by a preview; unvetted input is never evaluated.

2. let/const tab completion: globalLexicalScopeNames (src/jsc/bindings/NodeVM.cpp/.h)

V8 exposes Runtime.globalLexicalScopeNames; JSC has no equivalent, so lexically-declared names never completed. New globalLexicalScopeNames(context?) on the NodeVM binding enumerates the target global's globalLexicalEnvironment() symbol table (names only, symbols skipped). The shim session answers the inspector method with it. Verified under BUN_JSC_validateExceptionChecks=1.

3. process.config.variables.v8_enable_i18n_support (src/jsc/bindings/BunProcess.cpp)

Was misspelled v8_enable_i8n_support since it was added, so common.hasIntl was false in every vendored Node test (and in test/napi's vendored common) while Intl actually exists — test-repl-tab-complete's builtin-completion case caught it.

4. REPL require() error shape (src/js/internal/repl/node-shims.js makeRequireFunction)

A failing REPL require("./missing") threw Bun's ResolveMessage (Cannot find module './bar' from '…/<repl>', no requireStack). Node's loader contract is a plain Error with the Require stack:\n- <repl> message, code: 'MODULE_NOT_FOUND', and requireStack: ['<repl>'] — user code matches on all three. The shim reshapes only failures whose referrer is the REPL itself; a miss inside a required module keeps its own referrer message.

5. Deleted working directory (src/runtime/cli/Arguments.rs, src/runtime/cli/run_command.rs)

bun --interactive (and -e/-p) exited 1 with a bare ENOENT when the cwd had been deleted; node still boots there (process.cwd() throws on demand instead). Both unconditional getcwd calls at startup now fall back to the executable's directory, which is also what node anchors [eval] to.

Vendored tests (6, byte-verbatim, all passing)

Now 6 files: test-cwd-enoent-repl.js, test-cwd-enoent.js and test-cwd-enoent-preload.js below landed on main separately in #34660 and are no longer in this diff.

  • parallel/test-repl-mode.js
  • parallel/test-repl-custom-eval-previews.js
  • parallel/test-repl-strict-mode-previews.js
  • parallel/test-repl-reverse-search.js
  • parallel/test-repl-tab-complete.js (29 subtests)
  • parallel/test-repl-require.js
  • parallel/test-cwd-enoent-repl.js
  • parallel/test-cwd-enoent.js
  • parallel/test-cwd-enoent-preload.js

Full sweep of every test-repl* file in the tree passes on this branch (same set as base plus the six above), with one caveat: test-repl-completion-on-getters-disabled's heaviest subtest is borderline against node:test's 5s per-test timeout in debug builds only — ~5.5s on the base debug build, ~6.5s here (previews now actually evaluate, so the file accumulates more GC/JIT debt across its 7 subtests; isolated, the subtest's own work is unchanged — measured equal on both binaries). CI runs these on release builds where the subtest finishes in well under a second. Two mitigations are included anyway: declaration-keyword inputs skip the acorn vet entirely, and Runtime.callFunctionOn's inspect callback is compiled once per context instead of per keystroke.

Triaged and not vendored (with root cause)

Engine message/format walls (each fails on exactly one byte-asserted engine string):

  • test-repl-preview.js — everything passes except JSC's Unterminated regular expression literal '/0' vs V8's Invalid regular expression: missing /.
  • test-repl-preview-newlines.js — V8's not-a-function TypeError interpolates the value (real newline inside the message); JSC uses source text + (In …).
  • test-repl.js — V8's JSON.parse messages exceed Node's 80-col breakLength, forcing the Uncaught: wrap; JSC's short messages take the one-line path.
  • test-repl-pretty-stack.js — same rule, opposite side: JSC's Unexpected identifier 'y'. Expected ';' after variable declaration. is one char over 80.
  • test-repl-top-level-await.js — Return statements are only valid inside functions. vs Illegal return statement.
  • test-repl-underscore.js — V8 frame naming Object.readdirSync vs JSC readdirSync.
  • test-repl-unsafe-array-iteration.js — V8 interpolates the for-of source text ([3,2,1] is not iterable).

Runtime gaps root-caused during this work (tracked below, out of scope here):

  • test-repl-history-navigation.js — passes except one preview: error.stack materialized during GC loses its Name: message header. ErrorInstance::finalizeUnconditionally → VM::onComputeErrorInfo (the finalizer/String variant) never receives the instance, so the header hardcodes Error with no message. Repro: create an error in a vm context, Bun.gc(true), read .stack → first line is Error. Needs a WebKit-fork signature change (the JSValue variant already receives the JSObject*).
  • sequential/test-repl-timeout-throw.js — Bun's callback-style fs APIs are .then(cb) wrappers over the promise API, so a throwing user callback becomes an unhandledRejection instead of Node's fatal uncaughtException (repro: fs.readFile(f, () => { throw 0 }) — neither process.on('uncaughtException') nor the capture callback fires). Class bug across ~45 call sites in src/js/node/fs.ts; separate concern from this PR.
  • test-cwd-enoent-improved-message.js — needs process.cwd() to throw the uv_cwd ENOENT after the cwd is deleted; Bun returns the cached value (process area).
  • test-repl-inspector.js — needs an in-process node:inspector session with V8 response shapes (inspector area, gated).

Deliberate-divergence tests (need an owner's call, cannot pass verbatim):

cirospaciari and others added 4 commits July 25, 2026 02:15
The variable was added as "v8_enable_i8n_support", so anything probing
Node's spelling (including node test harnesses' common.hasIntl) saw
undefined and concluded Intl was unavailable.
…eted

Startup called getcwd() unconditionally in two places (argument parsing
and the [eval] entry-point path) and exited 1 with a bare ENOENT when the
cwd no longer existed. Node still boots there and anchors [eval] to the
executable's directory; do the same.

Vendors parallel/test-cwd-enoent.js, test-cwd-enoent-repl.js and
test-cwd-enoent-preload.js, which now pass.
Previews: Node posts Runtime.evaluate {throwOnSideEffect} on an inspector
session; the shim's sendInspectorCommand always errored, so setupPreview
emitted nothing. JSC has no side-effect-checking evaluator, so the shim
now implements the session: expressions are vetted statically first
(acorn AST allowlist, fail-closed; mutating methods only on receivers the
expression itself allocates) and only then run in the REPL's vm context,
with results returned as V8-shaped RemoteObjects. Session callbacks are
synchronous, which the double-eval of {-wrapped input relies on.
repl.js reports the created vm context to the session, replacing the
executionContextCreated event JSC's inspector cannot emit.

Tab completion: JSC has no Runtime.globalLexicalScopeNames, so let/const/
class bindings never completed. Adds a globalLexicalScopeNames(context)
binding that enumerates the target global lexical environment's symbol
table, and answers the inspector method with it.

require: a failing REPL require() threw the resolver's ResolveMessage.
Node's loader contract is a plain Error with the Require-stack message,
code MODULE_NOT_FOUND and requireStack: ['<repl>']; reshape exactly the
failures whose referrer is the REPL itself.

Vendors six upstream tests that now pass: test-repl-mode,
test-repl-custom-eval-previews, test-repl-strict-mode-previews,
test-repl-reverse-search, test-repl-tab-complete, test-repl-require.
@robobun

robobun commented Jul 25, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 11:04 PM PT - Aug 20th, 2026

❌ @robobun, your commit 5552bd0 has 1 failures in Build #102320 (All Failures):

  • 📦 Binary size — 12 over 0.50 MB
  • targetthis build canary: main #102263
    sizeΔ
    ❌ bun-darwin-aarch6460.98 MB58.65 MB+2.33 MB
    ❌ bun-darwin-x6466.90 MB64.71 MB+2.19 MB
    ❌ bun-linux-aarch6476.87 MB74.87 MB+2.00 MB
    ❌ bun-linux-x6477.04 MB75.02 MB+2.02 MB
    ❌ bun-linux-aarch64-musl70.20 MB68.20 MB+2.00 MB
    ❌ bun-linux-x64-musl71.07 MB69.06 MB+2.02 MB
    ❌ bun-linux-aarch64-android83.84 MB81.78 MB+2.06 MB
    ❌ bun-linux-x64-android86.26 MB84.28 MB+1.98 MB
    ❌ bun-freebsd-x6488.29 MB86.27 MB+2.02 MB
    ❌ bun-freebsd-aarch6491.44 MB89.33 MB+2.11 MB
    ❌ bun-windows-x6484.72 MB82.32 MB+2.40 MB
    ❌ bun-windows-aarch6474.95 MB73.03 MB+1.92 MB

    Add [skip size check] to the commit message if this increase is intentional.


🧪   To try this PR locally:

bunx bun-pr 35530

That installs a local version of the PR into your bun-35530 executable, so you can run:

bun-35530 --bun

robobun and others added 5 commits August 3, 2026 22:45
…de/node-repl-v26-wave2

No-Verification-Needed: automatic base-branch sync merge, no hand-authored changes
The process.config spelling fix flipped common.hasIntl to true and
un-skipped eleven unrelated Node parallel tests (url/icu/whatwg) that
Bun does not pass yet. Revert that one-line rename and instead gate the
repl-tab-complete "Intl" expectation on typeof Intl so the new test
still passes.

Also address the two remaining oxlint findings in node-shims.js: rename
the unused sendInspectorCommand parameter and hoist err.specifier into a
local before the conditional.
@robobun robobun changed the title node: repl v26 compat fixes (+9 tests) node: repl v26 compat fixes (+6 tests) Aug 21, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants