Repository navigation
node: repl v26 compat fixes (+6 tests) - #35530
Draft
cirospaciari wants to merge 10 commits into
Draft
cirospaciari wants to merge 10 commits into
cirospaciari wants to merge 10 commits into
Conversation
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.
Collaborator
|
Updated 11:04 PM PT - Aug 20th, 2026
❌ @robobun, your commit 5552bd0 has 1 failures in
Add 🧪 To try this PR locally: bunx bun-pr 35530That installs a local version of the PR into your bun-35530 --bun |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
…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.
…de/node-repl-v26-wave2
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/consttab completion, and Node-shaped REPLrequire()errors, plus a deleted-cwd startup fix and aprocess.configspelling 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'ssendInspectorCommandunconditionally calledonError(), sosetupPreviewnever 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: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);displayErrors: false; notimeout— JSC's Watchdog asserts on the REPL's re-entrant use, and the vet already rejects unbounded top-level constructs);value/unserializableValue/ opaqueobjectId), andRuntime.callFunctionOnruns the inspect callback in the same context. Callbacks fire synchronously — utils.js's double-eval of{-wrapped input depends on it.repl.jsgains one adapted line: aftervm.createContext(),session.contextCreated(context)echoes theRuntime.executionContextCreatedevent 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/consttab completion:globalLexicalScopeNames(src/jsc/bindings/NodeVM.cpp/.h)V8 exposes
Runtime.globalLexicalScopeNames; JSC has no equivalent, so lexically-declared names never completed. NewglobalLexicalScopeNames(context?)on the NodeVM binding enumerates the target global'sglobalLexicalEnvironment()symbol table (names only, symbols skipped). The shim session answers the inspector method with it. Verified underBUN_JSC_validateExceptionChecks=1.3.
process.config.variables.v8_enable_i18n_support(src/jsc/bindings/BunProcess.cpp)Was misspelled
v8_enable_i8n_supportsince it was added, socommon.hasIntlwas false in every vendored Node test (and in test/napi's vendored common) whileIntlactually exists —test-repl-tab-complete's builtin-completion case caught it.4. REPL
require()error shape (src/js/internal/repl/node-shims.jsmakeRequireFunction)A failing REPL
require("./missing")threw Bun'sResolveMessage(Cannot find module './bar' from '…/<repl>', norequireStack). Node's loader contract is a plainErrorwith theRequire stack:\n- <repl>message,code: 'MODULE_NOT_FOUND', andrequireStack: ['<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 unconditionalgetcwdcalls 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.jsandtest-cwd-enoent-preload.jsbelow landed on main separately in #34660 and are no longer in this diff.parallel/test-repl-mode.jsparallel/test-repl-custom-eval-previews.jsparallel/test-repl-strict-mode-previews.jsparallel/test-repl-reverse-search.jsparallel/test-repl-tab-complete.js(29 subtests)parallel/test-repl-require.jsparallel/test-cwd-enoent-repl.jsparallel/test-cwd-enoent.jsparallel/test-cwd-enoent-preload.jsFull 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, andRuntime.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'sUnterminated regular expression literal '/0'vs V8'sInvalid 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-colbreakLength, forcing theUncaught:wrap; JSC's short messages take the one-line path.test-repl-pretty-stack.js— same rule, opposite side: JSC'sUnexpected identifier 'y'. Expected ';' after variable declaration.is one char over 80.test-repl-top-level-await.js—Return statements are only valid inside functions.vsIllegal return statement.test-repl-underscore.js— V8 frame namingObject.readdirSyncvs JSCreaddirSync.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.stackmaterialized during GC loses itsName: messageheader.ErrorInstance::finalizeUnconditionally→VM::onComputeErrorInfo(the finalizer/String variant) never receives the instance, so the header hardcodesErrorwith no message. Repro: create an error in a vm context,Bun.gc(true), read.stack→ first line isError. Needs a WebKit-fork signature change (the JSValue variant already receives theJSObject*).sequential/test-repl-timeout-throw.js— Bun's callback-stylefsAPIs are.then(cb)wrappers over the promise API, so a throwing user callback becomes anunhandledRejectioninstead of Node's fataluncaughtException(repro:fs.readFile(f, () => { throw 0 })— neitherprocess.on('uncaughtException')nor the capture callback fires). Class bug across ~45 call sites insrc/js/node/fs.ts; separate concern from this PR.test-cwd-enoent-improved-message.js— needsprocess.cwd()to throw theuv_cwdENOENT after the cwd is deleted; Bun returns the cached value (process area).test-repl-inspector.js— needs an in-processnode:inspectorsession with V8 response shapes (inspector area, gated).Deliberate-divergence tests (need an owner's call, cannot pass verbatim):
test-force-repl.js— asserts theWelcome to Node.js v26.3.0.banner; ours is deliberately branded.test-force-repl-with-eval.js— needs-i -eto enter the REPL;-i -edeliberately keeps bun's--install=fallbackmeaning (repl: -i alias, --input-type rejection, builtin completion, directive parity, non-TTY mode (+2 tests, repl 77%→79%) #34642).test-repl-tab-complete-import.js/test-repl-tab-complete-require.js— upstream asserts anode:${lib}completion for every entry ofmodule.builtinModules; Bun's list deliberately includesbun:*names, which can never satisfynode:bun:ffi.