Skip to content

Asynchronous write() bug #2049

Closed
Closed
@jshkurti

Description

@jshkurti

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.processIssues and PRs related to the process subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions