diff --git a/.eslintrc b/.eslintrc index c90fa5e57ad13e..cb35d8fa0fa646 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,6 +10,7 @@ ecmaFeatures: generators: true forOf: true objectLiteralShorthandProperties: true + objectLiteralShorthandMethods: true rules: # Possible Errors diff --git a/lib/net.js b/lib/net.js index b5ae15e4692393..dd0bb94ab609e2 100644 --- a/lib/net.js +++ b/lib/net.js @@ -126,10 +126,7 @@ function Socket(options) { } else if (options.fd !== undefined) { this._handle = createHandle(options.fd); this._handle.open(options.fd); - if ((options.fd == 1 || options.fd == 2) && - (this._handle instanceof Pipe) && - process.platform === 'win32') { - // Make stdout and stderr blocking on Windows + if ((options.fd == 1 || options.fd == 2) && this._handle instanceof Pipe) { var err = this._handle.setBlocking(true); if (err) throw errnoException(err, 'setBlocking'); diff --git a/test/fixtures/stdout-producer.js b/test/fixtures/stdout-producer.js new file mode 100644 index 00000000000000..611425569df196 --- /dev/null +++ b/test/fixtures/stdout-producer.js @@ -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(); diff --git a/test/parallel/test-child-process-chunked-stdout.js b/test/parallel/test-child-process-chunked-stdout.js new file mode 100644 index 00000000000000..762d76475b4278 --- /dev/null +++ b/test/parallel/test-child-process-chunked-stdout.js @@ -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);