-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
strange befavior about console.err,console.log on win10 #18232
Comments
If I get this right, it is because the https://nodejs.org/api/process.html#process_a_note_on_process_i_o You can use this trick from the example of the second reference: const fs = require('fs');
const EventEmitter = require('events');
const emiter1 = new EventEmitter();
const emiter2 = new EventEmitter();
let cnt = 1;
emiter1.on('ping', () => {
fs.writeSync(1, `ping${cnt++}\n`);
emiter2.emit('pong');
})
emiter2.on('pong', () => {
fs.writeSync(1, `pong${cnt++}\n`);
emiter1.emit('ping');
})
emiter1.emit('ping'); |
thank you very much. I got the clue. |
vsemozhetbyt
added
console
Issues and PRs related to the console subsystem.
question
Issues that look for answers.
labels
Jan 19, 2018
This was referenced Apr 6, 2024
This was referenced Apr 6, 2024
This was referenced Apr 6, 2024
This was referenced Apr 6, 2024
This was referenced Apr 6, 2024
This was referenced Apr 6, 2024
This was referenced Apr 7, 2024
This was referenced Apr 7, 2024
This was referenced Apr 7, 2024
This was referenced Apr 7, 2024
This was referenced Oct 21, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stackoverflow: a strange behavior about the EventEmitter in node
I am learning EventEmitter. and I have a simple stupid test. (node --version v8.4.0 on win10)
I expect it will become a infinity function call, because emit() is a sync function.
Here is the output.:
Great! Just as I expected. But after I uncomment the cnt and console.log, I got a strange behavior. The program finished without an error, and stop at cnt==1600 (sometime is 1598, 1599)
Finally, I run
node em.js 1> out.txt 2> err.txt
and bothconsole.log
andconsole.err
are correct just as I expect. But I'm still wondering why the err didn't print out directly in my shell?Is there a reasonable explanation?
The text was updated successfully, but these errors were encountered: