Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Make native code context aware #102

Open
timfish opened this issue Mar 16, 2020 · 2 comments
Open

Make native code context aware #102

timfish opened this issue Mar 16, 2020 · 2 comments

Comments

@timfish
Copy link
Contributor

timfish commented Mar 16, 2020

Using node-usb-detection in Electron v8 I get the following warning output:

Electron: Loading non-context-aware native module in renderer: '\\?\C:\Users\tim\Documents\Repositories\AppName\node_modules\usb-detection\build\Release\detection.node'. This is deprecated, see https://github.com/electron/electron/issues/18397.

Details of how to fix this can be found at the listed issue:

What does this look like for Native Module X?

The amount of work to become "Context Aware" will be different for every module. For native modules that act as proxies for native getters and setters -- i.e. they just expose JS apis to acccess native APIs -- it's normally as easy as adding a NAN_MODULE_WORKER_ENABLED declaration. You can find an example of that in this pull request.

Some modules will need to do cleanup when the context is destroyed to ensure the module doesn't leaking memory or to cause crashes. You can add hooks to clean up after yourself with node::AddEnvironmentCleanupHook A minimal example of this can be found in this pull request.

@Lan-Hekary
Copy link

Hello,
Any news for this issue yet ??

@chsing
Copy link

chsing commented Jun 30, 2021

Hi,

Any update on this issue?

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants