Skip to content

Commit 698bffa

Browse files
aduh95targos
authored andcommitted
worker: refactor to avoid unsafe array iteration
PR-URL: #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>
1 parent 9417fd0 commit 698bffa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/main/worker_thread.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
const {
77
ArrayPrototypeConcat,
8+
ArrayPrototypeForEach,
89
ArrayPrototypeSplice,
910
ObjectDefineProperty,
1011
PromisePrototypeCatch,
@@ -181,8 +182,9 @@ port.on('message', (message) => {
181182
}
182183
} else if (message.type === STDIO_PAYLOAD) {
183184
const { stream, chunks } = message;
184-
for (const { chunk, encoding } of chunks)
185+
ArrayPrototypeForEach(chunks, ({ chunk, encoding }) => {
185186
process[stream].push(chunk, encoding);
187+
});
186188
} else {
187189
assert(
188190
message.type === STDIO_WANTS_MORE_DATA,

0 commit comments

Comments
 (0)