-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process suddenly terminating with exit code 0 #34
Comments
What Node.js version? Can you try with the absolute latest Node.js version? |
Sorry I didn't include the version. It's node 12.18.0, on windows. I will try with the absolute latest soon. |
Hi @sindresorhus, I just tried all 9 possible combinations of Windows, Linux and Mac with Node 14, 12, and 10. Each one of them gave the exact same output as above... 😮 (tried with github actions) |
Is it even possible that this behavior is |
I have no idea, to be honest, but why are you even using |
@sindresorhus Sorry for the delay. Indeed I could be iterating natively instead, thanks for the reminder! However, I just got into a similar situation, without Node.js readable streams. Here is a minimal example: // what.js
const pEvent = require('p-event');
const Emittery = require('emittery');
const emitter = new Emittery();
(async () => {
setTimeout(() => {
emitter.emit('data', 'foobar');
}, 500);
try {
console.log('A');
const asyncIterator = pEvent.iterator(emitter, 'data');
console.log('B');
for await (const event of asyncIterator) {
console.log('C', event);
}
console.log('D');
} catch {
console.log('E');
}
})(); Again, executing
In this example, I expected the process to hang indefinitely after printing |
This is a little scary... 😮 |
fs.createReadStream
For now, I am working around it with: const keepAlive = setTimeout(() => {}, (2 ** 31) - 1);
// ...
clearTimeout(keepAlive); |
I can no longer reproduce this on the latest version. Here's a modified version of the original report that works fine for me: import { pEventIterator } from "p-event";
import * as fs from "node:fs";
(async () => {
try {
console.log("A");
const asyncIterator = pEventIterator(
fs.createReadStream("package.json"),
"data",
{
resolutionEvents: ["close"],
},
);
console.log("B");
for await (const event of asyncIterator) {
console.log("C", event.length);
}
console.log("D");
} catch {
console.log("E");
}
})(); This logs:
I think this issue can be closed? |
I was experimenting with
pEvent.iterator
withfs.createReadStream
. See this very simple example:Executing
node what.js && echo success
gives:It does not log
D
norE
, and even exits with code 0! Do you have any idea what is going on here?The text was updated successfully, but these errors were encountered: