Skip to content

Correctly handle SharedArrayBuffer with structuredClone#6169

Merged
jasnell merged 1 commit intomainfrom
jasnell/structuredclone-edge-case
Feb 25, 2026
Merged

Correctly handle SharedArrayBuffer with structuredClone#6169
jasnell merged 1 commit intomainfrom
jasnell/structuredclone-edge-case

Conversation

@jasnell
Copy link
Copy Markdown
Collaborator

@jasnell jasnell commented Feb 25, 2026

Per the spec, SharedArrayBuffer cannot be transfered. There needs to be an error thrown.

@jasnell jasnell requested a review from anonrig February 25, 2026 03:32
@jasnell jasnell requested review from a team as code owners February 25, 2026 03:32
@jasnell jasnell enabled auto-merge February 25, 2026 03:32
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Feb 25, 2026

The analysis is complete. A bare SharedArrayBuffer passed to transfer would fall through to the else branch (since isArrayBuffer() returns false for SharedArrayBuffer) and throw TypeError: "Object is not transferable". That's already handled. The only dangerous path was a view backed by a SharedArrayBuffer, which this PR correctly fixes.

The code change is correct, well-commented, and prevents a V8 CHECK failure (process crash) that could occur when trying to detach a non-detachable buffer. The test covers the exact crash scenario. There's a minor typo in the test comment but nothing actionable.

LGTM

github run

@jasnell jasnell merged commit 6fcacf6 into main Feb 25, 2026
37 of 40 checks passed
@jasnell jasnell deleted the jasnell/structuredclone-edge-case branch February 25, 2026 05:03
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