Skip to content
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

Asynchronous write() bug #2049

Closed
jshkurti opened this issue Jun 24, 2015 · 2 comments
Closed

Asynchronous write() bug #2049

jshkurti opened this issue Jun 24, 2015 · 2 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. process Issues and PRs related to the process subsystem.

Comments

@jshkurti
Copy link

I have this sample code :

var big_str = '';
for (var i = 0; i < 1024*1024; big_str += 'a', ++i);
big_str += 'END';

process.stdout.write(big_str);

Everything works as expected. The entire string is displayed to the output.
Then I add process.exit()

var big_str = '';
for (var i = 0; i < 1024*1024; big_str += 'a', ++i);
big_str += 'END';

process.stdout.write(big_str);
process.exit(0);

I noticed the "END" was missing. So I did
node app.js | wc -c which returned 65536.

I'm guessing this is used as buffer size somewhere. But still, why is process.exit() being called before write() has finished ?

iojs v2.3.1

@jshkurti
Copy link
Author

Okay, process.stdout._handle.setBlocking(true) fixes the issue so I guess this PR #774 fixes it.
Will it be merged&published soon ?

@brendanashworth
Copy link
Contributor

It is a known issue of io.js, but the fix is wonky and requires a semver-major change. It wasn't landed in the last major but I'm not sure if it will be in 3.x. I'd recommend tracking #774 for the fix.

@brendanashworth brendanashworth added duplicate Issues and PRs that are duplicates of other issues or PRs. child_process Issues and PRs related to the child_process subsystem. process Issues and PRs related to the process subsystem. and removed child_process Issues and PRs related to the child_process subsystem. labels Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants