Skip to content

Commit b082520

Browse files
committed
n_api: fix fatalexception handling in workers
1 parent a8f4a1f commit b082520

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/node_api.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,10 +3354,11 @@ class Work : public node::AsyncResource {
33543354
// report it as a fatal exception. (There is no JavaScript on the
33553355
// callstack that can possibly handle it.)
33563356
if (!env->last_exception.IsEmpty()) {
3357-
v8::TryCatch try_catch(env->isolate);
3358-
env->isolate->ThrowException(
3359-
v8::Local<v8::Value>::New(env->isolate, env->last_exception));
3360-
node::FatalException(env->isolate, try_catch);
3357+
v8::Local<v8::Value> err = v8::Local<v8::Value>::New(
3358+
env->isolate, env->last_exception);
3359+
v8::Local<v8::Message> msg = v8::Exception::CreateMessage(
3360+
env->isolate, err);
3361+
node::FatalException(env->isolate, err, msg);
33613362
}
33623363
}
33633364
}

src/node_internals.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>& args) {
250250
args.GetReturnValue().Set(err);
251251
}
252252

253+
void FatalException(v8::Isolate* isolate,
254+
v8::Local<v8::Value> error,
255+
v8::Local<v8::Message> message);
256+
257+
253258
void SignalExit(int signo);
254259
#ifdef __POSIX__
255260
void RegisterSignalHandler(int signal,

0 commit comments

Comments
 (0)