mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
buffer: fix blob range error with many chunks
PR-URL: https://github.com/nodejs/node/pull/47320 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
@@ -69,6 +69,8 @@ const {
|
||||
CountQueuingStrategy,
|
||||
} = require('internal/webstreams/queuingstrategies');
|
||||
|
||||
const { queueMicrotask } = require('internal/process/task_queues');
|
||||
|
||||
const kHandle = Symbol('kHandle');
|
||||
const kType = Symbol('kType');
|
||||
const kLength = Symbol('kLength');
|
||||
@@ -284,7 +286,7 @@ class Blob {
|
||||
}
|
||||
if (buffer !== undefined)
|
||||
buffers.push(buffer);
|
||||
readNext();
|
||||
queueMicrotask(() => readNext());
|
||||
});
|
||||
};
|
||||
readNext();
|
||||
|
||||
@@ -315,3 +315,16 @@ assert.throws(() => new Blob({}), {
|
||||
|
||||
delete Object.prototype.type;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
// Refs: https://github.com/nodejs/node/issues/47301
|
||||
|
||||
const random = Buffer.alloc(256).fill('0');
|
||||
const chunks = [];
|
||||
|
||||
for (let i = 0; i < random.length; i += 2) {
|
||||
chunks.push(random.subarray(i, i + 2));
|
||||
}
|
||||
|
||||
await new Blob(chunks).arrayBuffer();
|
||||
})().then(common.mustCall());
|
||||
|
||||
Reference in New Issue
Block a user