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

Programmatic usage errors on Ctrl+C when specifying process.stdin #252

Closed
brandonchinn178 opened this issue Dec 25, 2020 · 0 comments · Fixed by #253
Closed

Programmatic usage errors on Ctrl+C when specifying process.stdin #252

brandonchinn178 opened this issue Dec 25, 2020 · 0 comments · Fixed by #253
Labels

Comments

@brandonchinn178
Copy link
Contributor

brandonchinn178 commented Dec 25, 2020

$ yarn node --version
v14.10.1

Using yarn versions 1.22.10 and 2.4.0

Repro

  1. yarn add concurrently
  2. Add script:
    const concurrently = require('concurrently')
    
    concurrently([
      'echo hi && sleep 100',
    ], {
      inputStream: process.stdin,
    }).catch(console.error)
  3. yarn node start.js

With yarn 1

Doing Ctrl+C on the yarn node start.js command will exit, but then hitting Enter again will show an error when NodeJS tries to read the line after exiting:

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

Error: read EIO
    at TTY.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -5,
  code: 'EIO',
  syscall: 'read'
}

With yarn 2

Run yarn set version berry before running yarn node start.js again. This time, when doing Ctrl+C, the script will hang until you do Ctrl+D

With node

Running just node start.js has the same behavior as yarn 2

Resolution

There's probably some code in concurrently that needs to stop listening to inputStream when the process exits. That should solve the problems with both yarn 1 and 2

Workaround

Manually destroying process.stdin after the process exits seems to fix

concurrently(...)
  .catch(console.error)
  .finally(() => {
    process.stdin.destroy()
  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants