Skip to content

EXC_BAD_ACCESS: Environment::GetCurrent returns nullptr in node::EmitAsyncDestroy #27218

@markandrus

Description

@markandrus
  • Version: v10.11.0
  • Platform: macOS
  • Subsystem: async_hooks

Hi, I'm porting my Native Addon from NAN to N-API and I've hit an issue. I have some objects which make use of node-addon-api's Napi::ObjectWrap and Napi::AsyncContext classes; however, I'm raising an issue here, because I'm not sure these are specific to node-addon-api. I actually hit a similar issue with NAN a while back (nodejs/nan#772).

What I see is that the call to Environment::GetCurrent(isolate) in node::EmitAsyncDestroy returns nullptr. I believe that is because this call to isolate->GetCurrentContext() returns nullptr. This results in an EXC_BAD_ACCESS.

You can see how I worked around this issue (starting with Node 9) when using NAN, although 1. it's probably incorrect and 2. it relies on v8 APIs that I don't want to use when porting to N-API.

Is this a bug? Am I doing something wrong? Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    node-apiIssues and PRs related to the Node-API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions