electron/spec/fixtures/api/utility-process/non-cloneable.js
Shelley Vohr 8e8ea3ee8b
fix: MessagePort closing unexpectedly with non-cloneable objects (#42535)
* fix: MessagePort closing unexpectedly with non-cloneable objects

* fix: handle serialization failure in parentPort
2024-06-19 11:27:07 +02:00

11 lines
300 B
JavaScript

const nonClonableObject = () => {};
process.parentPort.on('message', () => {
try {
process.parentPort.postMessage(nonClonableObject);
} catch (error) {
if (/An object could not be cloned/.test(error.message)) {
process.parentPort.postMessage('caught-non-cloneable');
}
}
});