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

tty: process.stdin.write() throws #22905

Closed
mcollina opened this issue Sep 17, 2018 · 7 comments
Closed

tty: process.stdin.write() throws #22905

mcollina opened this issue Sep 17, 2018 · 7 comments
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. libuv Issues and PRs related to the libuv dependency or the uv binding. tty Issues and PRs related to the tty subsystem.

Comments

@mcollina
Copy link
Member

mcollina commented Sep 17, 2018

  • Version: 10 (since libuv 1.20)
  • Platform: all
  • Subsystem: tty, net

This behavior is a regression caused by libuv (see libuv/libuv#1936 and #21654).

Currently:

process.stdin.write('hello')

Throws

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:79:25)
    at writeGeneric (internal/stream_base_commons.js:74:3)
    at ReadStream.Socket._writeGeneric (net.js:715:5)
    at ReadStream.Socket._write (net.js:727:8)
    at doWrite (_stream_writable.js:410:12)
    at writeOrBuffer (_stream_writable.js:394:5)
    at ReadStream.Writable.write (_stream_writable.js:294:11)
    at Object.<anonymous> (/Users/matteo/Repositories/node/a.js:1:77)
    at Module._compile (internal/modules/cjs/loader.js:693:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
Emitted 'error' event at:
    at onwriteError (_stream_writable.js:425:12)
    at onwrite (_stream_writable.js:456:5)
    at _destroy (internal/streams/destroy.js:40:7)
    at ReadStream.Socket._destroy (net.js:615:3)
    at ReadStream.destroy (internal/streams/destroy.js:32:8)
    at afterWriteDispatched (internal/stream_base_commons.js:79:17)
    at writeGeneric (internal/stream_base_commons.js:74:3)
    [... lines matching original stack trace ...]
    at doWrite (_stream_writable.js:410:12)

Is this error acceptable/understandable, or should we do a custom error like #21654?

@mcollina
Copy link
Member Author

cc @addaleax

@addaleax
Copy link
Member

I think it would be okay to keep this the way it is – if we do want to provide a better error message, we should probably create a custom one for EPIPE? It’s weird that we don’t already include at least strerror(EPIPE) like we do for other errors…

@addaleax
Copy link
Member

And, again, I think this is a bug – stdin could definitely be a duplex or writable stream. And process.stdin might be a sensible way to access the current TTY if stdout/stderr are redirected to some file but stdin isn’t.

@addaleax addaleax added libuv Issues and PRs related to the libuv dependency or the uv binding. tty Issues and PRs related to the tty subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Sep 17, 2018
@mcollina
Copy link
Member Author

cc @cjihrig

@mcollina
Copy link
Member Author

I think it would be okay to keep this the way it is – if we do want to provide a better error message, we should probably create a custom one for EPIPE? It’s weird that we don’t already include at least strerror(EPIPE) like we do for other errors…

I'm ok in keeping it the way it is now.

@Trott
Copy link
Member

Trott commented Nov 24, 2018

I'm ok in keeping it the way it is now.

Should this remain open or be closed?

@addaleax
Copy link
Member

As far as I can tell, this has actually been fixed (partially in libuv). → Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. libuv Issues and PRs related to the libuv dependency or the uv binding. tty Issues and PRs related to the tty subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants