Skip to content

src: add buildflag to force context-aware addons

This PR adds a new cli flag --force-context-aware whose purpose is to prevent usage of native node addons that aren't context aware. In an embedder context, loading native addons ahas always been challenging due to the need to rebuild, to link to the right node.lib/dll, and to ensure the NODE_MODULE_VERSION is correct.

Since Node doesn't let you load multiple instances of a native module in the same process, even in different v8 contexts, this creates a host of problems for multi-process framework like Electron.

This new flag would allow Electron and other embedders to enforce restrictions more cleanly and prevent unexpected behavior.

More context for embedders can be found here: #18397

cc @MarshallOfSound

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading