fix: don't crash Utility Processes on unhandled rejections (#45921)

* fix: don't crash on unhandled rejections

* Update docs/breaking-changes.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
This commit is contained in:
Shelley Vohr 2025-03-14 15:09:02 +01:00 committed by GitHub
parent 5817d27429
commit c0e180758b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -14,6 +14,19 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (36.0)
### Utility Process unhandled rejection behavior change
Utility Processes will now warn with an error message when an unhandled
rejection occurs instead of crashing the process.
To restore the previous behavior, you can use:
```js
process.on('uncaughtException', () => {
process.exit(1)
})
```
### Removed:`isDefault` and `status` properties on `PrinterInfo`
These properties have been removed from the PrinterInfo Object

View file

@ -155,6 +155,9 @@ void NodeService::Initialize(
node_env_->set_trace_sync_io(node_env_->options()->trace_sync_io);
// We do not want to crash the utility process on unhandled rejections.
node_env_->options()->unhandled_rejections = "warn-with-error-code";
// Add Electron extended APIs.
electron_bindings_->BindTo(node_env_->isolate(), node_env_->process_object());