Skip to content

Move NodeRT to N-API or make it context-aware (Electron renderer processes in >v14)  #158

Open
@felixrieseberg

Description

@felixrieseberg

Most of today's NodeRT users use it to call native Windows methods from Node.js or Electron. In order to do so safely in Electron's renderer process, NodeRT has to move to N-API or be otherwise made context-aware.

From Node.js's docs:

There are environments in which Node.js addons may need to be loaded multiple times in multiple contexts. For example, the Electron runtime runs multiple instances of Node.js in a single process. Each instance will have its own require() cache, and thus each instance will need a native addon to behave correctly when loaded via require(). This means that the addon must support multiple initializations.

Until Electron 14, NodeRT could still be loaded safely in renderer processes by using the process.allowRendererProcessReuse option. In the future, this will no longer be possible, meaning that NodeRT should not be loaded in renderer processes.

Options for Electron/NodeRT users

  1. require() NodeRT only in the main process and use Electron's IPC to marshal calls between the main and the renderer process. This is what I, Felix, would do right now.
  2. Move NodeRT to N-API. This is the right solution to the problem and would improve NodeRT dramatically, but I probably don't have the time to do this anytime soon.
  3. Make NodeRT context-aware using NAN's helpers. Easier than option 2, but still work.

I'll gladly accept all pull requests helping here.

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