worker: refactor to avoid unsafe array iteration

PR-URL: https://github.com/nodejs/node/pull/37346
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Harshitha K P <harshitha014@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Antoine du Hamel authored and Michaël Zasso committed 2021-06-11 09:29:59 +02:00
1 parent 9417fd0bc8
commit 698bffaa90
1 file changed
+3 -1
+3 -1
View File
@@ -5,6 +5,7 @@
const {
ArrayPrototypeConcat,
ArrayPrototypeForEach,
ArrayPrototypeSplice,
ObjectDefineProperty,
PromisePrototypeCatch,
@@ -181,8 +182,9 @@ port.on('message', (message) => {
}
} else if (message.type === STDIO_PAYLOAD) {
const { stream, chunks } = message;
for (const { chunk, encoding } of chunks)
ArrayPrototypeForEach(chunks, ({ chunk, encoding }) => {
process[stream].push(chunk, encoding);
});
} else {
assert(
message.type === STDIO_WANTS_MORE_DATA,