Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: correct concat() error message #29198

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ Buffer.concat = function concat(list, length) {
// TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE.
// Instead, find the proper error code for this.
throw new ERR_INVALID_ARG_TYPE(
`list[${i}]`, ['Array', 'Buffer', 'Uint8Array'], list[i]);
`list[${i}]`, ['Buffer', 'Uint8Array'], list[i]);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`list[${i}]`, ['Buffer', 'Uint8Array'], list[i]);
`list[${i}]`, ['Buffer', 'Uint8Array'], buf);

}
_copy(buf, buffer, pos);
pos += buf.length;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ assert.strictEqual(flatLongLen.toString(), check);
Buffer.concat(value);
}, {
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "list[0]" argument must be one of type Array, Buffer, ' +
message: 'The "list[0]" argument must be one of type Buffer ' +
`or Uint8Array. Received type ${typeof value[0]}`
});
});
Expand All @@ -68,7 +68,7 @@ assert.throws(() => {
Buffer.concat([Buffer.from('hello'), 3]);
}, {
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "list[1]" argument must be one of type Array, Buffer, ' +
message: 'The "list[1]" argument must be one of type Buffer ' +
'or Uint8Array. Received type number'
});

Expand Down