Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the native addon context-aware #118

Closed
wants to merge 1 commit into from

Conversation

bongnv
Copy link

@bongnv bongnv commented Nov 15, 2022

Since Electron 14, all native add-ons must be context-aware. Therefore, in order to make node-tree-sitter run with Electron >= 14, it has to be context-aware. Ref: electron/electron#18397

In this PR, NAN_MODULE_WORKER_ENABLED is used to make the native addon context-aware. It will allow context as the third param but will ignore context. Although context param will be accepted, this change doesn't mean that the addon will be safe to be initialised multiple times and can be run safely on worker threads. Perhaps, someone with a better understanding of the library helps to implement AddEnvironmentCleanupHook to clean up global static resources. Ref: https://nodejs.org/api/addons.html#context-aware-addons

Another minor change: xcode_settings settings are consolidated into a single place.

Since Electron 14, all native addons must be context-aware. Therefore,
in order to make node-tree-sitter run with Electron >= 14, it has to be
context-aware. Ref: electron/electron#18397

In this commit, NAN_MODULE_WORKER_ENABLED is used to make the native
addon context-aware. It will allow context as the third param but will
ignore it. This change doesn't mean that the addon will be safe
to be initialised multiple times so can be run on worker threads
though. Perhaps, someone with better understanding of the library need
to implement AddEnvironmentCleanupHook to clean up resources. Ref:
https://nodejs.org/api/addons.html#context-aware-addons
@verhovsky verhovsky changed the title fix: make the native addon to be context-aware fix: make the native addon context-aware Jun 21, 2023
@segevfiner
Copy link
Contributor

It won't really be context aware without also taking care of any static references to JS values the module currently uses.

@segevfiner
Copy link
Contributor

My PR for making it truly context aware was merged, this one can be closed.

@amaanq amaanq closed this Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants