Buffer.concat ignores a nonnumeric totalLength

Open
#3,889 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, typescript
Domain
backend

Research direction

Start by tracing SharpTS's implementation of Buffer.concat and how it handles the optional totalLength argument; the issue provides a JavaScript reproduction and Node.js v22.23.2 behavior to compare against. Run the reproduction in SharpTS and its IL-verified standalone, then find the relevant tests or add a regression case. Done when a nonnumeric totalLength produces the same TypeError and ERR_INVALID_ARG_TYPE behavior as Node.js.

Written by the indexing model from the issue text.

Description

Found while testing #3884. Run this as JavaScript.

const concat = Buffer.concat;
try { console.log(concat([Buffer.of(65)], '2').toString('hex')); }
catch (e) { console.log(e.name, e.code); }

Node.js v22.23.2 prints TypeError ERR_INVALID_ARG_TYPE. SharpTS interpretation and an IL-verified standalone infer the length and print 41.

Dominant language
C#
Stars
156
Forks
4
Avg merge
13h 20m
Merged PRs (30d)
47

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nickna/SharpTS

All issues in nickna/SharpTS

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.