Multithreading
It is possible to use Node.js features in Electron’s Web Workers, to do so the option should be set to true
in webPreferences
.
All built-in modules of Node.js are supported in Web Workers, and asar
archives can still be read with Node.js APIs. However none of Electron’s built-in modules can be used in a multi-threaded environment.
Note that even if a native Node.js module is thread-safe it’s still not safe to load it in a Web Worker because the function is not thread safe.
throw new Error('Load native module is not safe')