Repository navigation
Class: Buffer do not follow when the underlying ArrayBuffer is resized #52195
Copy link
Copy link
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
Activity
- addedbufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.and removeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Mar 24, 2024 Behavior comes from:
Lines 476 to 505 in bae14b7
function fromArrayBuffer(obj, byteOffset, length) { // Convert byteOffset to integer if (byteOffset === undefined) { byteOffset = 0; } else { byteOffset = +byteOffset; if (NumberIsNaN(byteOffset)) byteOffset = 0; } const maxLength = obj.byteLength - byteOffset; if (maxLength < 0) throw new ERR_BUFFER_OUT_OF_BOUNDS('offset'); if (length === undefined) { length = maxLength; } else { // Convert length to non-negative integer. length = +length; if (length > 0) { if (length > maxLength) throw new ERR_BUFFER_OUT_OF_BOUNDS('length'); } else { length = 0; } } return new FastBuffer(obj, byteOffset, length); } byteOffsetandlengthare initiallyundefined, but the function ensures they are numbers, and if they are specified, the typed array's length stays fixed./cc @nodejs/buffer
Bufferhas always been assumed to be non-resizable. I'm wondering if the right fix for now shouldn't be to forbid creating aBufferfrom a resizableArrayBufferuntil we can make sure that all ofBuffer's APIs handle it appropriatelyI'm wondering if the right fix for now shouldn't be to forbid creating a Buffer from a resizable ArrayBuffer until we can make sure that all of Buffer's APIs handle it appropriately
This will break me. Please don't.
- added a commit that references this issue
on Oct 13, 2024 - added a commit that references this issue
on Oct 15, 2024 - added a commit that references this issue
on Oct 19, 2024 - added a commit that references this issue
on Nov 27, 2024
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Version
v21.7.1
Platform
Microsoft Windows NT 10.0.22631.0 x64
Subsystem
Class: Buffer
What steps will reproduce the bug?
Output:
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
Expecting buffer to be resized and output to be:
<Buffer ff 01 02 03 04 05 06 07>What do you see instead?
<Buffer ff 01 02 03>Additional information
If the resolution to this is that Buffer isn't going to support ArrayBuffer.resize() that should be reflected in the documentation.