Skip to content

Commit

Permalink
tweak(scripting/v8node): use Node.js' unhandled promise rejection han…
Browse files Browse the repository at this point in the history
…dler

This is for compatibility with code expecting Node.js-like behavior.
  • Loading branch information
blattersturm committed Jun 12, 2023
1 parent 4650611 commit 6e54fc9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion code/components/citizen-scripting-v8/src/V8ScriptRuntime.cpp
Expand Up @@ -2889,6 +2889,7 @@ void V8ScriptGlobals::Initialize()
}
#endif

#ifndef V8_NODE
m_isolate->SetPromiseRejectCallback([](PromiseRejectMessage message)
{
Local<Promise> promise = message.GetPromise();
Expand All @@ -2906,6 +2907,9 @@ void V8ScriptGlobals::Initialize()

scRT->HandlePromiseRejection(message);
});
#else
m_isolate->SetPromiseRejectCallback(node::PromiseRejectCallback);
#endif

Isolate::Initialize(m_isolate, params);

Expand Down Expand Up @@ -2986,7 +2990,8 @@ void V8ScriptGlobals::Initialize()
#else
"",
#endif
"--expose-internals"
"--expose-internals",
"--unhandled-rejections=warn",
};

for (int i = 1; i < g_argc; i++)
Expand Down

0 comments on commit 6e54fc9

Please sign in to comment.