Skip to content

Inspector: handle BigInt/Symbol in jsToInspectorValue instead of asserting - #384

Open
robobun wants to merge 1 commit into
mainfrom
claude/inspector-bigint-symbol-returnbyvalue
Open

robobun wants to merge 1 commit into
mainfrom
claude/inspector-bigint-symbol-returnbyvalue

Conversation

@robobun

@robobun robobun commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

What

Runtime.evaluate / Runtime.callFunctionOn / Debugger.evaluateOnCallFrame with returnByValue: true on a result that holds a BigInt or Symbol reached ASSERT_NOT_REACHED in Inspector::jsToInspectorValue, aborting an assertions build. Release builds fell through to nullptr and the caller reported the unrelated "Object has too long reference chain (must not be longer than 1000)" error.

Reproduces with any of: [1n], ({a:1n}), Symbol("s"), ({b:Symbol()}). A bare top-level 1n is fine because InjectedScriptSource.js never stores it on RemoteObject.value.

Fix

  • Add an explicit isBigInt() || isSymbol() arm to jsToInspectorValue that returns nullptr (unserializable) instead of falling into ASSERT_NOT_REACHED.
  • Replace the "Object has too long reference chain" error string in makeCall / makeAsyncCall with "Object couldn't be returned by value", matching V8's inspector wording and accurate for both the depth-limit and the unserializable-primitive cases.

Repro

bun --inspect=127.0.0.1:<port>/tok -e "setInterval(()=>{},1000)" &
# connect WebSocket to ws://127.0.0.1:<port>/tok, send:
{"id":1,"method":"Runtime.evaluate","params":{"expression":"[1n]","returnByValue":true}}

Assertions build before: SHOULD NEVER BE REACHED in InjectedScriptBase.cpp:96, SIGABRT.
Release before: {"error":{"code":-32000,"message":"Object has too long reference chain ..."}}.
After: {"error":{"code":-32000,"message":"Object couldn't be returned by value"}} on both, debuggee stays alive.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Limit details: You’ve used all 5 included reviews currently available under your plan.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a53c9cad-d756-467a-ba32-c04e9f992c16

📥 Commits

Reviewing files that changed from the base of the PR and between 0cbb4a1 and 739b330.

📒 Files selected for processing (1)
  • Source/JavaScriptCore/inspector/InjectedScriptBase.cpp

Walkthrough

Changes

Inspector value conversion

Layer / File(s) Summary
Conversion handling and error reporting
Source/JavaScriptCore/inspector/InjectedScriptBase.cpp
jsToInspectorValue treats BigInt and Symbol values as non-representable JSON values. Synchronous and asynchronous conversion failures now report "Object couldn't be returned by value".
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the change to BigInt and Symbol handling in jsToInspectorValue.
Description check ✅ Passed The description clearly explains the bug, affected APIs, reproduction, fix, and resulting behavior, but it omits the required Bugzilla link and reviewer line.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Source/JavaScriptCore/inspector/InjectedScriptBase.cpp`:
- Around line 69-74: Add regression tests for the non-JSON handling in
InjectedScriptBase, covering direct 1n, direct Symbol(), and nested [1n] values
with returnByValue enabled. Exercise synchronous and asynchronous
Runtime.evaluate and Runtime.callFunctionOn flows, plus
Debugger.evaluateOnCallFrame where supported, and assert the "Object couldn't be
returned by value" error while confirming execution completes without reaching
ASSERT_NOT_REACHED.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 904ce0ce-dc1a-4f63-8543-0825b32e83ff

📥 Commits

Reviewing files that changed from the base of the PR and between e6e37cd and 0cd81ac.

📒 Files selected for processing (1)
  • Source/JavaScriptCore/inspector/InjectedScriptBase.cpp

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — small, well-scoped fix that stops the inspector from asserting on BigInt/Symbol under returnByValue and gives a clearer error string.

What was reviewed:

  • Verified JSValue::isBigInt() covers both BigInt32 and HeapBigInt, and isSymbol() guards on isCell() — safe to call at that point in the type ladder.
  • Placement before isObject() is correct; these were the only primitive kinds that previously fell through to ASSERT_NOT_REACHED.
  • Confirmed nothing else in the tree matches the old "Object has too long reference chain" string, so the message change is self-contained.
Extended reasoning...

Overview

The PR touches a single file, Source/JavaScriptCore/inspector/InjectedScriptBase.cpp, with two changes: (1) an early return nullptr in jsToInspectorValue when the value is a BigInt or Symbol, and (2) rewording the error string produced by makeCall / makeAsyncCall when toInspectorValue returns null. Net effect: an assertions build no longer aborts when Runtime.evaluate with returnByValue: true encounters a BigInt/Symbol, and release builds report a message that actually describes the failure.

Security risks

None. This is inspector-protocol serialization code that runs only when a debugger is attached. The new branch does no allocation or coercion — it just returns nullptr, which was already the release-build behavior via the ASSERT_NOT_REACHED(); return nullptr; fallthrough. The error-string change is a literal constant.

Level of scrutiny

Low. The diff is ~10 lines, mechanical, and confined to a debugging/inspector path. The release-build semantics for the BigInt/Symbol case are unchanged (still nullptr); only the debug-build assert and the user-facing error text differ. I checked JSCJSValueCell.h to confirm isBigInt() handles both the BigInt32 tag and heap BigInts and that isSymbol() is a null-safe cell-type check, so the new arm slots correctly between the existing primitive checks and the isObject() branch.

Other factors

A repo-wide grep found no other consumers of the old "Object has too long reference chain" string, so nothing depends on the exact wording. The new message matches V8's inspector wording per the PR description, which is a reasonable choice for tooling compatibility. No prior review comments or bot findings on this PR.

@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Preview Builds

Commit Release Date
739b330d autobuild-preview-pr-384-739b330d 2026-08-16 11:23:40 UTC
0cd81acb autobuild-preview-pr-384-0cd81acb 2026-08-03 19:16:05 UTC

…rting

Runtime.evaluate / Runtime.callFunctionOn with returnByValue:true on a
result that contains a BigInt or Symbol (for example [1n], {a:1n}, or
Symbol()) reached the ASSERT_NOT_REACHED at the end of
jsToInspectorValue, aborting an assertions build. Release builds fell
through to nullptr and the caller reported the unrelated 'Object has too
long reference chain' message.

Return nullptr explicitly for BigInt and Symbol (they have no JSON
representation), and replace the misleading depth-limit message with the
same 'Object couldn't be returned by value' wording V8's inspector uses.
toInspectorValue also returns nullptr when a getter throws during
serialization, so the new wording is accurate for every nullptr path.
@robobun
robobun force-pushed the claude/inspector-bigint-symbol-returnbyvalue branch from 0cd81ac to 739b330 Compare August 16, 2026 10:38

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — small, defensive fix that stops the debug-build assert and gives a clearer error for unserializable inspector results.

What was reviewed:

  • Verified JSValue::isBigInt() / isSymbol() exist and that these types are cells but not objects, so they previously fell through to ASSERT_NOT_REACHED.
  • Confirmed the new nullptr return follows the same pattern as the existing depth-limit and recursive-element failure paths, and both callers already handle it.
  • Grepped for the old "Object has too long reference chain" string — no other consumers, so the wording change is safe; JSON::Value::create(const String&) accepts the new String("..."_s) form.
Extended reasoning...

Overview

This PR touches a single file, Source/JavaScriptCore/inspector/InjectedScriptBase.cpp, with three small hunks:

  1. In jsToInspectorValue, add an if (value.isBigInt() || value.isSymbol()) return nullptr; arm after the primitive checks and before the isObject() branch.
  2. In makeCall, replace the fallback error string when toInspectorValue returns null.
  3. In makeAsyncCall, make the identical string replacement in the async lambda.

The intent is to stop Runtime.evaluate / callFunctionOn with returnByValue: true from hitting ASSERT_NOT_REACHED (SIGABRT in assertions builds) when the result contains a BigInt or Symbol, and to replace the misleading "too long reference chain" message with V8-compatible wording that also covers the depth-limit case.

Security risks

None. This is inspector/devtools JSON serialization for the returnByValue protocol path. The change adds an early-out that returns nullptr for two primitive types that were already falling through to nullptr in release builds — it just makes that explicit and skips the assertion. No new data is exposed, no auth/permissions logic is touched, and the error string is a static literal.

Level of scrutiny

Low. The change is narrowly scoped to inspector error reporting, not the JS runtime or JIT tiers. In release builds the observable behavior change is only the error-message text (nullptr was already returned via the ASSERT_NOT_REACHED fallthrough); in debug builds it prevents a crash. I verified JSValue::isBigInt() and JSValue::isSymbol() are defined in JSCJSValue.h, and that BigInt (heap or BigInt32) and Symbol are non-object cells, so the placement before isObject() is correct — they never entered that branch. The recursive array/object handlers already check for a null child and propagate nullptr, so nested [1n] / {a:1n} are handled without further changes.

Other factors

  • Grepped the tree for the old error string — no tests, layout tests, or other code match it, so rewording is safe.
  • JSON::Value::create(const String&) exists and create(T) = delete would reject a bare ASCIILiteral, so the explicit String("..."_s) wrapper is the right construction.
  • The only prior review activity is a resolved CodeRabbit nit asking for regression tests; no outstanding human-reviewer comments.
  • The bug hunting system found no issues.

robobun added a commit to oven-sh/bun that referenced this pull request Aug 16, 2026
Runtime.evaluate (and callFunctionOn / evaluateOnCallFrame) with
returnByValue:true on a result that contains a BigInt or Symbol reached
ASSERT_NOT_REACHED in Inspector::jsToInspectorValue, aborting an
assertions build of the debuggee. Release builds fell through to nullptr
and reported the unrelated 'Object has too long reference chain' error.

The fix is in oven-sh/WebKit#384: jsToInspectorValue now returns nullptr
explicitly for BigInt/Symbol (they have no JSON representation), and the
error surfaced to the client is 'Object couldn't be returned by value'
(matching V8's inspector). Bump WEBKIT_VERSION to pick that up and add a
--inspect regression test for [1n], {a:1n}, Symbol(), {b:Symbol()}.
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