From 65e8864fa39fb51250d63212548807589cba08f3 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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`. PR-URL: https://github.com/nodejs/node/pull/36242 Reviewed-By: Gireesh Punathil Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Juan José Arboleda Reviewed-By: Antoine du Hamel --- 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; } }