node/test/addons/report-fatalerror/binding.cc
legendecas 466710c298
report: print javascript stack on fatal error
Try to print JavaScript stack on fatal error. OOMError needs to be
distinguished from fatal error since no new handle can be created at
that time.

PR-URL: https://github.com/nodejs/node/pull/44242
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2022-08-20 12:34:34 +08:00

23 lines
506 B
C++

#include <node.h>
#include <v8.h>
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::MaybeLocal;
using v8::Object;
using v8::Value;
void TriggerFatalError(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
// Trigger a v8 ApiCheck failure.
MaybeLocal<Value> value;
value.ToLocalChecked();
}
void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "triggerFatalError", TriggerFatalError);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, init)