diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index ac2b75f24575b8..58bb46e8a27a0e 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -238,17 +238,7 @@ function flushStdio(subprocess) { function createSocket(pipe, readable) { - var s = new net.Socket({ handle: pipe }); - - if (readable) { - s.writable = false; - s.readable = true; - } else { - s.writable = true; - s.readable = false; - } - - return s; + return net.Socket({ handle: pipe, readable, writable: !readable }); } diff --git a/test/async-hooks/test-pipewrap.js b/test/async-hooks/test-pipewrap.js index 550de7907a168a..066458841fabab 100644 --- a/test/async-hooks/test-pipewrap.js +++ b/test/async-hooks/test-pipewrap.js @@ -78,7 +78,7 @@ function onexit() { // Usually it is just one event, but it can be more. assert.ok(ioEvents >= 3, `at least 3 stdout io events, got ${ioEvents}`); - checkInvocations(pipe1, { init: 1, before: 2, after: 2 }, + checkInvocations(pipe1, { init: 1, before: 1, after: 1 }, 'pipe wrap when sleep.spawn was called'); checkInvocations(pipe2, { init: 1, before: ioEvents, after: ioEvents }, 'pipe wrap when sleep.spawn was called');