Skip to content

Document that the ObjectWrap example code doesn't work for multi-context usage #711

@geekuillaume

Description

@geekuillaume

After spending a day trying to debug why I had so many seemingly random issues with my code, I finally understood why: the object wrap example code is not compatible with a multi-context usage of the addon.

Explanation: this example set the constructor static member of the class to a reference of the constructor function but if the addon is loaded multiple time (with worker_threads for example), the value is overwritten by a new reference in the new context. That makes this reference unusable to create new instances of this wrapped class from other C++ code and makes any code wanting to use this reference in another context crash.

We should at least make sure there is a warning about this in the documentation. The best would be to provide a workaround with the new addon instance data support maybe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions