Closed
Description
- Version: v9.2.0 and v8.9.1, probably other version also affected
- Platform: linux
- Subsystem: -
I run this code inside docker with -m 100m --memory-swap 100m
, and then the program crash after few second
function doWork() {
// ... do real work with some sleep at the end, but for demo purpose i just return (async) resolved promise
return new Promise(a => setImmediate(a));
}
var exit = false;
const exitPromise = new Promise(a => {
process.once('SIGINT', () => {
exit = true;
a();
});
});
(async () => {
console.log('start');
while(!exit) {
await Promise.race([exitPromise, doWork()]);
}
console.log('stop');
})().catch(console.error.bind(console));
but it perfectly fine when i change await Promise.race([exitPromise, doWork()]);
with await doWork();