diff --git a/docs/tutorial/process-model.md b/docs/tutorial/process-model.md index ea2ce8c5b271b..4769d90021b33 100644 --- a/docs/tutorial/process-model.md +++ b/docs/tutorial/process-model.md @@ -214,8 +214,25 @@ This feature is incredibly useful for two main purposes: URL, you can add custom properties onto the renderer's `window` global that can be used for desktop-only logic on the web client's side. +## The utility process + +Each Electron app can spawn multiple child processes from the main process using +the [UtilityProcess][] API. The utility process runs in a Node.js environment, +meaning it has the ability to `require` modules and use all of Node.js APIs. +The utility process can be used to host for example: untrusted services, +CPU intensive tasks or crash prone components which would have previously +been hosted in the main process or process spawned with Node.js [`child_process.fork`][] API. +The primary difference between the utility process and process spawned by Node.js +child_process module is that the utility process can establish a communication +channel with a renderer process using [`MessagePort`][]s. An Electron app can +always prefer the [UtilityProcess][] API over Node.js [`child_process.fork`][] API when +there is need to fork a child process from the main process. + [window-mdn]: https://developer.mozilla.org/en-US/docs/Web/API/Window +[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort +[`child_process.fork`]: https://nodejs.org/dist/latest-v16.x/docs/api/child_process.html#child_processforkmodulepath-args-options [context-isolation]: ./context-isolation.md [context-bridge]: ../api/context-bridge.md [ipcrenderer]: ../api/ipc-renderer.md +[UtilityProcess]: ../api/utility-process.md [tutorial]: ./tutorial-1-prerequisites.md