Skip to content

Concatenate untyped Buffer lists as Node does - #1272

Open
ctate wants to merge 6 commits into
mainfrom
ctate/concatenate-untyped-buffer-0eeb9b
Open

ctate wants to merge 6 commits into
mainfrom
ctate/concatenate-untyped-buffer-0eeb9b

Conversation

@ctate

@ctate ctate commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator
  • Buffer.concat accepts lists whose type is not a static Buffer[] (such as JavaScript's untyped arrays), checking them at run time with Node's ERR_INVALID_ARG_TYPE errors instead of stopping at an SC2020 fence.

Buffer.concat lowered only a statically typed Buffer[]/Uint8Array[] list
or an array literal. Any other list, such as JavaScript's
`const chunks = []`, reached an SC2020 fence at run time. Such lists now
go to the runtime, which checks them as Node does (an Array whose
elements are Uint8Arrays, ERR_INVALID_ARG_TYPE with Node's messages
otherwise) before concatenating; the length form is covered as well.
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 18, 2026 6:18pm UTC

}
scr_arr_push_ref(parts, scr_bytes_retain(shown->v.bytes));
scr_dyn_release(item);
}

@vercel vercel Bot Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In Buffer.concat(list, length)'s untyped two-argument path, element-type validation runs before length validation, so an invalid element throws ERR_INVALID_ARG_TYPE before Node would throw the length ERR_OUT_OF_RANGE, diverging from Node's error ordering.

Fix on Vercel

With untyped Buffer.concat lists and typeof on builtin module exports supported, the fixture runs to completion and matches Node, so its expected deferred SC2020 refusal is removed.

This branch was successfully deployed

1 active deployment
Preview — ead270ca Deployed Oct 18, 2026 by vercel[bot]
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