Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ext/node/polyfills/worker_threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class NodeWorker extends EventEmitter {
#messagePromise = undefined;
#controlPromise = undefined;
#workerOnline = false;
#exited = false;
// "RUNNING" | "CLOSED" | "TERMINATED"
// "TERMINATED" means that any controls or messages received will be
// discarded. "CLOSED" means that we have received a control
Expand Down Expand Up @@ -229,6 +230,11 @@ class NodeWorker extends EventEmitter {
switch (type) {
case 1: { // TerminalError
this.#status = "CLOSED";
if (!this.#exited) {
this.#exited = true;
this.emit("exit", 1);
}
return;
} /* falls through */
case 2: { // Error
this.#handleError(data);
Expand All @@ -237,6 +243,10 @@ class NodeWorker extends EventEmitter {
case 3: { // Close
debugWT(`Host got "close" message from worker: ${this.#name}`);
this.#status = "CLOSED";
if (!this.#exited) {
this.#exited = true;
this.emit("exit", 0);
}
return;
}
default: {
Expand Down Expand Up @@ -314,7 +324,6 @@ class NodeWorker extends EventEmitter {
if (this.#status !== "TERMINATED") {
this.#status = "TERMINATED";
op_host_terminate_worker(this.#id);
this.emit("exit", 0);
}
return PromiseResolve(0);
}
Expand Down
Loading