diff --git a/src/api/environment.cc b/src/api/environment.cc index 68395a61675b09..648f0184c35c76 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -231,9 +231,11 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) { s.fatal_error_callback : OnFatalError; isolate->SetFatalErrorHandler(fatal_error_cb); - auto* prepare_stack_trace_cb = s.prepare_stack_trace_callback ? - s.prepare_stack_trace_callback : PrepareStackTraceCallback; - isolate->SetPrepareStackTraceCallback(prepare_stack_trace_cb); + if ((s.flags & SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK) == 0) { + auto* prepare_stack_trace_cb = s.prepare_stack_trace_callback ? + s.prepare_stack_trace_callback : PrepareStackTraceCallback; + isolate->SetPrepareStackTraceCallback(prepare_stack_trace_cb); + } } void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { diff --git a/src/node.h b/src/node.h index 0286655c7ada89..c9487bfa79b692 100644 --- a/src/node.h +++ b/src/node.h @@ -316,7 +316,8 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { enum IsolateSettingsFlags { MESSAGE_LISTENER_WITH_ERROR_LEVEL = 1 << 0, DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1, - SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2 + SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2, + SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3 }; struct IsolateSettings {