From 5b52cafde55cc96bb6e30d2c18be2dc1b06c3d57 Mon Sep 17 00:00:00 2001 From: Yash Ladha Date: Tue, 24 Nov 2020 08:26:56 +0530 Subject: [PATCH] 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`. --- src/node_worker.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/node_worker.cc b/src/node_worker.cc index 15dea5c501b101..43a3862cc69dc3 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -150,9 +150,7 @@ class WorkerThreadData { Isolate* isolate = Isolate::Allocate(); if (isolate == nullptr) { - // TODO(addaleax): This should be ERR_WORKER_INIT_FAILED, - // ERR_WORKER_OUT_OF_MEMORY is for reaching the per-Worker heap limit. - w->Exit(1, "ERR_WORKER_OUT_OF_MEMORY", "Failed to create new Isolate"); + w->Exit(1, "ERR_WORKER_INIT_FAILED", "Failed to create new Isolate"); return; } @@ -298,9 +296,7 @@ void Worker::Run() { TryCatch try_catch(isolate_); context = NewContext(isolate_); if (context.IsEmpty()) { - // TODO(addaleax): This should be ERR_WORKER_INIT_FAILED, - // ERR_WORKER_OUT_OF_MEMORY is for reaching the per-Worker heap limit. - Exit(1, "ERR_WORKER_OUT_OF_MEMORY", "Failed to create new Context"); + Exit(1, "ERR_WORKER_INIT_FAILED", "Failed to create new Context"); return; } }