new Blob([new Uint16Array([1])]) has size 1 instead of 2 #40705
Closed
Description
Version
v16.13.0
Platform
Darwin vashli.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
If you run following with node 16.3
node -e 'assert.equal(new (require("buffer").Blob)([new Uint16Array([1])]).size, 2)'
Produces output
node:assert:123
throw new AssertionError(obj);
AssertionError [ERR_ASSERTION]: 1 == 2
at [eval]:1:8
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:81:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:80:60)
at node:internal/main/eval_string:27:3 {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: 1,
expected: 2,
operator: '=='
}
Which mismatches expected Blob
behavior
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
assert should pass and generally blob behavior should match one from web
What do you see instead?
No response
Additional information
Issue with the following line
Lines 109 to 128 in dd52c05
Which should return following instead
source = new Uint8Array(source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength));
return [source.byteLength, source];