Skip to content

Commit cafae5d

Browse files
alan-agius4metcoder95
authored andcommitted
fix: prevent race condition in idle worker cleanup (#818)
1 parent 53130ea commit cafae5d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/worker_pool/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export class WorkerInfo extends AsynchronouslyCreatedResource {
121121
};
122122

123123
try {
124+
this.clearIdleTimeout();
124125
this.port.postMessage(message, taskInfo.transferList);
125126
} catch (err) {
126127
// This would mostly happen if e.g. message contains unserializable data
@@ -132,7 +133,6 @@ export class WorkerInfo extends AsynchronouslyCreatedResource {
132133
taskInfo.workerInfo = this;
133134
this.taskInfos.set(taskInfo.taskId, taskInfo);
134135
this.ref();
135-
this.clearIdleTimeout();
136136

137137
// Inform the worker that there are new messages posted, and wake it up
138138
// if it is waiting for one.

0 commit comments

Comments
 (0)