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

fix: make stdout flush on newer versions of Node.js #501

Merged
merged 5 commits into from May 15, 2016
Merged

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented May 14, 2016

see #497

if (process.stdout._handle && typeof process.stdout._handle.setBlocking === 'function') {
process.stdout._handle.setBlocking(true)
process.stderr._handle.setBlocking(true)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution seems fine to me.

One note: If _handle exists it's always a net.Socket (or inherits from it), and thus setBlocking() will always exist.
(This has not been changed in years.)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm curious, does this actually work when done retroactively?

If you have async writes and they you do this does it immediately cause a blocking flush on call? If you don't know, that's fine, I'll investigate.

Copy link
Member Author

@bcoe bcoe May 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fishrock123 trying to go make sure yargs supports all the way back to 0.8 currently:

Benjamins-MBP:yargs benjamincoe$ node --version
v0.8.28
Benjamins-MBP:yargs benjamincoe$ node
> process.stdout._handle.setBlocking
undefined

was hoping it would work retroactively, and tried this initially, it does not appear to. You need to have set blocking to true before you begin writing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was added in v0.11.2: nodejs/node@20176a9 in response to nodejs/node-v0.x-archive#3584

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this doesn't ever manifest as an issue before 0.11.2 then, but I haven't tested it.

@coveralls
Copy link

coveralls commented May 14, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 4f6b6a4 on node-6-fix into 796285d on master.

@bcoe bcoe merged commit 9f8c6f4 into master May 15, 2016
@nexdrew nexdrew deleted the node-6-fix branch August 3, 2016 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants