Skip to content

c++ nan exception unhanding #3693

Closed as not planned
Closed as not planned

Description

@mohammadmoth

Details

Sometimes something goes wrong and I can't catch the error.
What it does is to close the program without giving any reason for the error.
Without executing any of the pre-exit operations such as events in process .

I reproduced the problem by throwing a exception , As in the example below

Node.js version

  • Node v14.17.5
  • nan 2.14.2

Example code

https://github.com/nodejs/node-addon-examples/tree/main/3_callbacks/nan

#include <nan.h>

void RunCallback(const Nan::FunctionCallbackInfo<v8::Value>& info) {
  throw;
  v8::Local<v8::Function> cb = info[0].As<v8::Function>();
  const unsigned argc = 1;
  v8::Local<v8::Value> argv[argc] = {Nan::New("hello world").ToLocalChecked()};
  Nan::AsyncResource resource("nan:makeCallback");
  resource.runInAsyncScope(Nan::GetCurrentContext()->Global(), cb, argc, argv);
}

void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
  Nan::SetMethod(module, "exports", RunCallback);
}

NODE_MODULE(addon, Init)

var addon = require('bindings')('addon');

addon(function(msg){
  console.log(msg); // 'hello world'
});

Please note that I added "throw"

Operating system

Windows 10

Scope

runtime

Module and version

Not applicable.

Activity

  1. github-actions commented on May 8, 2024

    @github-actions

    It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment.
    If you need further assistance or have questions, you can also search for similar issues on Stack Overflow.
    Make sure to look at the README file for the most updated links.

  2. github-actions commented on Jun 8, 2024

    @github-actions

    It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment.
    If you need further assistance or have questions, you can also search for similar issues on Stack Overflow.
    Make sure to look at the README file for the most updated links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions