I found an issue after the change I made for the timeout.
The Promise.race generated based without timeout control can't hang the process.
This code, for example, should never finish, by common sense:
const {
EventEmitter
} = require("events");
const forEmitOf = require("./dist");
const {
sleep
} = require("./dist/sleep");
async function test() {
const neverEmit = new EventEmitter();
for await (const item of forEmitOf(neverEmit)) {
console.log(`never will print ${item}`);
}
}
test();
But node can't keep the process alive from the existence of a promise created base only in event listeners. If you run the code, you'll see that node just finish abruptly.
I found an issue after the change I made for the timeout.
The Promise.race generated based without timeout control can't hang the process. This code, for example, should never finish, by common sense:
But node can't keep the process alive from the existence of a promise created base only in event listeners. If you run the code, you'll see that node just finish abruptly.