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

ENOTCONN thrown when calling process.stdin.end() in node 10.1.0 #22814

Closed
cristianberroeta opened this issue Sep 12, 2018 · 0 comments
Closed

Comments

@cristianberroeta
Copy link

  • Version: 10.1.0, 10.9.0, 10.10.0 (probably every version between 10.1.0 and 10.10.0)
  • Platform: Darwin iMac 17.6.0 Darwin Kernel Version 17.6.0: Tue May 8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64

Hi all,

If I run this file:

process.stdin.end();

using node 10.1.0, 10.9.0 or 10.10.0, it throws an ENOTCONN error.

This is the output when using node 10.1.0:

cbm test $ node index.js
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: shutdown ENOTCONN
    at ReadStream.Socket._final (net.js:369:25)
    at callFinal (_stream_writable.js:615:10)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:721:11)
    at startup (internal/bootstrap/node.js:228:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
Emitted 'error' event at:
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)

But when using node 10.0.0, no error is thrown.

Is that a bug?


It may seem useless, but I'm actually trying to solve this bug for code that looks more like this:

try {
    process.stdin.pipe(process.stdout);
    setTimeout(() => {
        process.stdin.end();
    }, 2000);
} catch (error) {
    console.log('ERROR:');
    console.log(error);
}

So the code I'm working on uses process.stdin.end(); to finish the program. It indeed finishes, but only after throwing the error. By the way (and I don't know if it has something to do with this issue), if I use process.stdin.destroy(); instead of process.stdin.end();, it works as expected.

mcollina added a commit to mcollina/node that referenced this issue Sep 17, 2018
addaleax pushed a commit to addaleax/node that referenced this issue Sep 24, 2018
@danbev danbev closed this as completed in 9577946 Oct 4, 2018
targos pushed a commit that referenced this issue Oct 4, 2018
PR-URL: #23051
Fixes: #22814
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: George Adams <[email protected]>
Reviewed-By: James M Snell <[email protected]>
jasnell pushed a commit that referenced this issue Oct 17, 2018
PR-URL: #23051
Fixes: #22814
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: George Adams <[email protected]>
Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this issue Mar 19, 2019
Backport-PR-URL: #25351
PR-URL: #23051
Fixes: #22814
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: George Adams <[email protected]>
Reviewed-By: James M Snell <[email protected]>
abhishekumar-tyagi pushed a commit to abhishekumar-tyagi/node that referenced this issue May 5, 2024
PR-URL: nodejs/node#23051
Fixes: nodejs/node#22814
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: George Adams <[email protected]>
Reviewed-By: James M Snell <[email protected]>
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 a pull request may close this issue.

1 participant