Skip to content

Commit 47c276c

Browse files
committed
worker: send correct error status for worker init
When the worker is created, in case of failure when a separate isolate is not able to get created, we tend to throw out of memory error for that worker which is not the case. Correct error code as per semantic should be thrown which is in our case is `ERR_WORKER_INIT_FAILED`.
1 parent 5325376 commit 47c276c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/node_worker.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ class WorkerThreadData {
149149

150150
Isolate* isolate = Isolate::Allocate();
151151
if (isolate == nullptr) {
152-
// TODO(addaleax): This should be ERR_WORKER_INIT_FAILED,
153-
// ERR_WORKER_OUT_OF_MEMORY is for reaching the per-Worker heap limit.
154-
w->Exit(1, "ERR_WORKER_OUT_OF_MEMORY", "Failed to create new Isolate");
152+
w->Exit(1, "ERR_WORKER_INIT_FAILED", "Failed to create new Isolate");
155153
return;
156154
}
157155

@@ -297,9 +295,7 @@ void Worker::Run() {
297295
TryCatch try_catch(isolate_);
298296
context = NewContext(isolate_);
299297
if (context.IsEmpty()) {
300-
// TODO(addaleax): This should be ERR_WORKER_INIT_FAILED,
301-
// ERR_WORKER_OUT_OF_MEMORY is for reaching the per-Worker heap limit.
302-
Exit(1, "ERR_WORKER_OUT_OF_MEMORY", "Failed to create new Context");
298+
Exit(1, "ERR_WORKER_INIT_FAILED", "Failed to create new Context");
303299
return;
304300
}
305301
}

0 commit comments

Comments
 (0)