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
.
Note: This option is not available in or Service Workers owing to incompatibilities in sandboxing policies.
Any native Node.js module can be loaded directly in Web Workers, but it is strongly recommended not to do so. Most existing native modules have been written assuming single-threaded environment, using them in Web Workers will lead to crashes and memory corruptions.
The only way to load a native module safely for now, is to make sure the app loads no native modules after the Web Workers get started.
throw new Error('Load native module is not safe')