Skip to content

[REPL] Builtin objects cannot be accessed after delete globalThis - #2

Draft
wind-stream-staging[bot] wants to merge 1 commit into
mainfrom
factory/repl-builtin-objects-cannot-be-accessed-xv6s6h
Draft

wind-stream-staging[bot] wants to merge 1 commit into
mainfrom
factory/repl-builtin-objects-cannot-be-accessed-xv6s6h

Conversation

@wind-stream-staging

Copy link
Copy Markdown

Duplicate of nodejs#67702

Version

v27.0.0-alpha.0.1.1

Platform

Microsoft Windows NT 10.0.26300.0 x64

Subsystem

No response

What steps will reproduce the bug?

In node repl:

> delete globalThis
true
> Math
Uncaught Error [ERR_INSPECTOR_NOT_AVAILABLE]: Inspector is not available
    at ReplInspectorChannel.toLiveValue (node:internal/repl/inspector:202:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5) {
  code: 'ERR_INSPECTOR_NOT_AVAILABLE'
}
> JSON
Uncaught Error [ERR_INSPECTOR_NOT_AVAILABLE]: Inspector is not available
    at ReplInspectorChannel.toLiveValue (node:internal/repl/inspector:202:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5) {
  code: 'ERR_INSPECTOR_NOT_AVAILABLE'
}

What's more, when an undefined identifier is entered, the input behavior never stops.

> delete globalThis
true
> a
| b
| c
| ;
| !@#$%^&[]
|

How often does it reproduce? Is there a required condition?

always

Source: #1


Opened by Wind Stream's factory at the brief owner's request. The change was produced in an isolated sandbox run and verified into Wind Stream custody before this pull request was opened; nothing was pushed from a developer machine.

  • Base: main at a337566
  • Sandbox run srun_1QkE87DNomQcLgLHLOK7, attempt satt_dUw4mVE8jchA4kJvuP8h (codex, gpt-6.1-sol)
  • Candidate sha256 38d114834c8008de1723baa07f2c4c098f4733b14263fb4584a2a7d2a2844271

WS: session-iCXlj-X5OfXAjOex7EzHc

Duplicate of nodejs#67702

WS: session-iCXlj-X5OfXAjOex7EzHc
Factory-Run: srun_1QkE87DNomQcLgLHLOK7
Factory-Attempt: satt_dUw4mVE8jchA4kJvuP8h
Candidate-SHA256: 38d114834c8008de1723baa07f2c4c098f4733b14263fb4584a2a7d2a2844271
@dshaw

dshaw commented Nov 24, 2026

Copy link
Copy Markdown

Comparison with the upstream proposal

Factory independently found the same line as the upstream author. After a user deletes globalThis, the REPL inspector can no longer use it to return a live object or exception. This patch fixes the reported case by looking up __nodeREPLStash directly. Original Node.js issue

The two fixes differ when a user declares a variable with the same name as that internal storage. The Factory code still resolves the name in the user’s context. The upstream implementation captures an inspector handle to the storage object before user code runs and passes it directly when retrieving a value. That design was in the first upstream commit. The change to inspector message serialization came later during review. First upstream commit · Upstream PR

For a follow-up, I’d pair upstream’s object-handle approach with the regression test from this PR. It checks that the next command runs normally after an unknown name raises a ReferenceError. It also checks that a genuinely incomplete expression still accepts multiline input.

@dshaw

dshaw commented Nov 24, 2026

Copy link
Copy Markdown

Validation of the Factory candidate

I compared this PR at 7ffca8edb755 with upstream at cf7baaa82a2a using the same V8 inspector harness on Node 24.11.0. Each row checks retrieval of Math, JSON, and the ReferenceError from an unknown name. The results below held in both the global context and an isolated REPL context.

Case Original inspector This PR Upstream proposal
Delete globalThis, then retrieve the three values 0/3 3/3 3/3
Declare a variable with the same name as the internal storage, then repeat 0/3 0/3 3/3

Separately, the Factory worker reported that its new regression test failed on the baseline and passed with the patch, alongside seven existing focused REPL tests. It ran the checkout’s REPL/readline JavaScript on Node 24.11.0. Native Node 27, Windows, ESLint, and full CI were outside that run.

For this first Factory build, the result demonstrates an independently produced fix for the reported behavior, a regression test that exercises the user-visible symptoms, and a reviewable patch delivered to the fork.

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.

1 participant