-
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
net: make stdout & stderr block on all platforms #1771
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
// Produce a very long string, so that stdout will have to break it into chunks. | ||
var str = 'test\n'; | ||
for (var i = 0; i < 17; i++, str += str); | ||
|
||
// Add something so that we can identify the end. | ||
str += 'hey\n'; | ||
|
||
process.stdout.write(str); | ||
|
||
// Close the process, attempting to close before | ||
// all chunked stdout writes are done. | ||
// | ||
// This is required to achieve the regression described in | ||
// https://github.com/nodejs/io.js/issues/784. | ||
process.exit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
EDIT: It's probably a bad idea in general to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood, however, I'm not able to produce the regression without it, what do you suggest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, can you add a comment explaining that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, though I'm not sure of the specifics. I could take a dive into it if need be. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const fork = require('child_process').fork; | ||
const stream = require('stream'); | ||
const path = require('path'); | ||
|
||
const producer = fork(path.join(common.fixturesDir, 'stdout-producer.js'), | ||
{ silent: true }); | ||
|
||
var output = ''; | ||
const writable = new stream.Writable({ | ||
write(chunk, _, next) { | ||
output += chunk.toString(); | ||
next(); | ||
} | ||
}); | ||
|
||
producer.stdout.pipe(writable); | ||
producer.stdout.on('close', function() { | ||
assert(output.endsWith('hey\n'), | ||
'Not all chunked writes were completed before process termination.'); | ||
}); | ||
|
||
producer.stderr.pipe(process.stderr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used here: https://github.com/nodejs/io.js/pull/1771/files#diff-7718507eb7a71106a68401cae76c5268R14
I don't see a good reason not to enable these other than backporting, maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, we had to enable one of these in #1760 already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I only needed one here, but might as well enable both.