Ghost/ghost/job-manager/test/jobs/message.js
Naz 6b2494a5bc Bumped bree to 6.2.0
refs 55060e323c

- This bump was meant to be done when the referenced changes landed. Without it parts of worker thread messages are lost
2021-03-03 12:26:37 +13:00

21 lines
464 B
JavaScript

const {parentPort} = require('bthreads');
setInterval(() => { }, 10);
if (parentPort) {
parentPort.on('message', (message) => {
if (message === 'error') {
throw new Error('oops');
}
if (message === 'cancel') {
parentPort.postMessage('cancelled');
return;
}
// post the message back
parentPort.postMessage(`Worker received: ${message}`);
process.exit(0);
});
}