Skip to content

Commit 5b52caf

Browse files
yashLadhaaduh95
authored andcommitted
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 52f9aaf commit 5b52caf

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
@@ -150,9 +150,7 @@ class WorkerThreadData {
150150

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

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

0 commit comments

Comments
 (0)