Skip to content

Conversation

@thatguystone
Copy link
Contributor

Description

If stdin.on('data') isn't called, 'end' is never emitted. This works in interactive mode (ie. stdin.isTTY) since readline drains stdin.

If stdin.on('data') isn't called, 'end' is never emitted. This works in
interactive mode (ie. stdin.isTTY) since readline drains stdin.
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give a repro or show an example of what this fixes? In what case would you run a dev server in non-interactive mode in non-CI?

@thatguystone
Copy link
Contributor Author

Can you give a repro or show an example of what this fixes?

import subprocess
import sys

proc = subprocess.Popen(
    ["./node_modules/.bin/vite"],
    stdin=subprocess.PIPE,
    stdout=sys.stdout,
    stderr=sys.stderr,
)
proc.stdin.close()
proc.wait(timeout=1.0)

In this case, pre-patch, it fails with TimeoutExpired, and vite will continue running indefinitely in the background. For the CI and non-CI case, vite should probably reliably exit when its stdin is closed.

import subprocess
import sys

proc = subprocess.Popen(
    ["./node_modules/.bin/vite"],
    stdin=sys.stdin,
    stdout=sys.stdout,
    stderr=sys.stderr,
)

When run with stdin.isTTY, vite continues in the background but eventually exits with:

node:events:486
      throw er; // Unhandled 'error' event
      ^

Error: read EIO
    at TTY.onStreamRead (node:internal/stream_base_commons:216:20)
Emitted 'error' event on Interface instance at:
    at ReadStream.onerror (node:internal/readline/interface:259:10)
    at ReadStream.emit (node:events:508:28)
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -5,
  code: 'EIO',
  syscall: 'read'
}

Node.js v24.8.0

In what case would you run a dev server in non-interactive mode in non-CI?

I run vite serve with a number of other services, all managed by a single runner; a couple of them can run in interactive mode, but it doesn't make much sense for them all to fight over stdin, so none get stdin.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! Makes sense to me

@bluwy bluwy changed the title fix(dev): drain stdin when not interactive fix(server): drain stdin when not interactive Sep 26, 2025
@thatguystone
Copy link
Contributor Author

Can this be merged?

@kentcdodds
Copy link

Sadly this broke my use case: #20884

bluwy added a commit that referenced this pull request Oct 3, 2025
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 3, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 7.1.7 | 7.1.8 |


## [v7.1.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-718-2025-10-02-small)

##### Bug Fixes

- **css:** improve url escape characters handling ([#20847](vitejs/vite#20847)) ([24a61a3](vitejs/vite@24a61a3))
- **deps:** update all non-major dependencies ([#20855](vitejs/vite#20855)) ([788a183](vitejs/vite@788a183))
- **deps:** update artichokie to 0.4.2 ([#20864](vitejs/vite#20864)) ([e670799](vitejs/vite@e670799))
- **dev:** skip JS responses for document requests ([#20866](vitejs/vite#20866)) ([6bc6c4d](vitejs/vite@6bc6c4d))
- **glob:** fix HMR for array patterns with exclusions ([#20872](vitejs/vite#20872)) ([63e040f](vitejs/vite@63e040f))
- keep ids for virtual modules as-is ([#20808](vitejs/vite#20808)) ([d4eca98](vitejs/vite@d4eca98))
- **server:** drain stdin when not interactive ([#20837](vitejs/vite#20837)) ([bb950e9](vitejs/vite@bb950e9))
- **server:** improve malformed URL handling in middlewares ([#20830](vitejs/vite#20830)) ([d65a983](vitejs/vite@d65a983))

##### Documentation

- **create-vite:** provide deno example ([#20747](vitejs/vite#20747)) ([fdb758a](vitejs/vite@fdb758a))

##### Miscellaneous Chores

- **deps:** update rolldown-related dependencies ([#20810](vitejs/vite#20810)) ([ea68a88](vitejs/vite@ea68a88))
- **deps:** update rolldown-related dependencies ([#20854](vitejs/vite#20854)) ([4dd06fd](vitejs/vite@4dd06fd))
- update url of `create-react-app` license ([#20865](vitejs/vite#20865)) ([166a178](vitejs/vite@166a178))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 3, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 7.1.7 | 7.1.9 |


## [v7.1.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-719-2025-10-03-small)

##### Reverts

- **server:** drain stdin when not interactive ([#20885](vitejs/vite#20885)) ([12d72b0](vitejs/vite@12d72b0))


## [v7.1.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-718-2025-10-02-small)

##### Bug Fixes

- **css:** improve url escape characters handling ([#20847](vitejs/vite#20847)) ([24a61a3](vitejs/vite@24a61a3))
- **deps:** update all non-major dependencies ([#20855](vitejs/vite#20855)) ([788a183](vitejs/vite@788a183))
- **deps:** update artichokie to 0.4.2 ([#20864](vitejs/vite#20864)) ([e670799](vitejs/vite@e670799))
- **dev:** skip JS responses for document requests ([#20866](vitejs/vite#20866)) ([6bc6c4d](vitejs/vite@6bc6c4d))
- **glob:** fix HMR for array patterns with exclusions ([#20872](vitejs/vite#20872)) ([63e040f](vitejs/vite@63e040f))
- keep ids for virtual modules as-is ([#20808](vitejs/vite#20808)) ([d4eca98](vitejs/vite@d4eca98))
- **server:** drain stdin when not interactive ([#20837](vitejs/vite#20837)) ([bb950e9](vitejs/vite@bb950e9))
- **server:** improve malformed URL handling in middlewares ([#20830](vitejs/vite#20830)) ([d65a983](vitejs/vite@d65a983))

##### Documentation

- **create-vite:** provide deno example ([#20747](vitejs/vite#20747)) ([fdb758a](vitejs/vite@fdb758a))

##### Miscellaneous Chores

- **deps:** update rolldown-related dependencies ([#20810](vitejs/vite#20810)) ([ea68a88](vitejs/vite@ea68a88))
- **deps:** update rolldown-related dependencies ([#20854](vitejs/vite#20854)) ([4dd06fd](vitejs/vite@4dd06fd))
- update url of `create-react-app` license ([#20865](vitejs/vite#20865)) ([166a178](vitejs/vite@166a178))
@laurentpayot
Copy link
Contributor

For the record, it also broke my F# (.Net) launch of a vite preview process. Only working in a brand new shell window.

renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 4, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 7.1.7 | 7.1.9 |


## [v7.1.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-719-2025-10-03-small)

##### Reverts

- **server:** drain stdin when not interactive ([#20885](vitejs/vite#20885)) ([12d72b0](vitejs/vite@12d72b0))


## [v7.1.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-718-2025-10-02-small)

##### Bug Fixes

- **css:** improve url escape characters handling ([#20847](vitejs/vite#20847)) ([24a61a3](vitejs/vite@24a61a3))
- **deps:** update all non-major dependencies ([#20855](vitejs/vite#20855)) ([788a183](vitejs/vite@788a183))
- **deps:** update artichokie to 0.4.2 ([#20864](vitejs/vite#20864)) ([e670799](vitejs/vite@e670799))
- **dev:** skip JS responses for document requests ([#20866](vitejs/vite#20866)) ([6bc6c4d](vitejs/vite@6bc6c4d))
- **glob:** fix HMR for array patterns with exclusions ([#20872](vitejs/vite#20872)) ([63e040f](vitejs/vite@63e040f))
- keep ids for virtual modules as-is ([#20808](vitejs/vite#20808)) ([d4eca98](vitejs/vite@d4eca98))
- **server:** drain stdin when not interactive ([#20837](vitejs/vite#20837)) ([bb950e9](vitejs/vite@bb950e9))
- **server:** improve malformed URL handling in middlewares ([#20830](vitejs/vite#20830)) ([d65a983](vitejs/vite@d65a983))

##### Documentation

- **create-vite:** provide deno example ([#20747](vitejs/vite#20747)) ([fdb758a](vitejs/vite@fdb758a))

##### Miscellaneous Chores

- **deps:** update rolldown-related dependencies ([#20810](vitejs/vite#20810)) ([ea68a88](vitejs/vite@ea68a88))
- **deps:** update rolldown-related dependencies ([#20854](vitejs/vite#20854)) ([4dd06fd](vitejs/vite@4dd06fd))
- update url of `create-react-app` license ([#20865](vitejs/vite#20865)) ([166a178](vitejs/vite@166a178))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 5, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 7.1.7 | 7.1.9 |


## [v7.1.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-719-2025-10-03-small)

##### Reverts

- **server:** drain stdin when not interactive ([#20885](vitejs/vite#20885)) ([12d72b0](vitejs/vite@12d72b0))


## [v7.1.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-718-2025-10-02-small)

##### Bug Fixes

- **css:** improve url escape characters handling ([#20847](vitejs/vite#20847)) ([24a61a3](vitejs/vite@24a61a3))
- **deps:** update all non-major dependencies ([#20855](vitejs/vite#20855)) ([788a183](vitejs/vite@788a183))
- **deps:** update artichokie to 0.4.2 ([#20864](vitejs/vite#20864)) ([e670799](vitejs/vite@e670799))
- **dev:** skip JS responses for document requests ([#20866](vitejs/vite#20866)) ([6bc6c4d](vitejs/vite@6bc6c4d))
- **glob:** fix HMR for array patterns with exclusions ([#20872](vitejs/vite#20872)) ([63e040f](vitejs/vite@63e040f))
- keep ids for virtual modules as-is ([#20808](vitejs/vite#20808)) ([d4eca98](vitejs/vite@d4eca98))
- **server:** drain stdin when not interactive ([#20837](vitejs/vite#20837)) ([bb950e9](vitejs/vite@bb950e9))
- **server:** improve malformed URL handling in middlewares ([#20830](vitejs/vite#20830)) ([d65a983](vitejs/vite@d65a983))

##### Documentation

- **create-vite:** provide deno example ([#20747](vitejs/vite#20747)) ([fdb758a](vitejs/vite@fdb758a))

##### Miscellaneous Chores

- **deps:** update rolldown-related dependencies ([#20810](vitejs/vite#20810)) ([ea68a88](vitejs/vite@ea68a88))
- **deps:** update rolldown-related dependencies ([#20854](vitejs/vite#20854)) ([4dd06fd](vitejs/vite@4dd06fd))
- update url of `create-react-app` license ([#20865](vitejs/vite#20865)) ([166a178](vitejs/vite@166a178))
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 6, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 7.1.7 | 7.1.9 |


## [v7.1.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-719-2025-10-03-small)

##### Reverts

- **server:** drain stdin when not interactive ([#20885](vitejs/vite#20885)) ([12d72b0](vitejs/vite@12d72b0))


## [v7.1.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-718-2025-10-02-small)

##### Bug Fixes

- **css:** improve url escape characters handling ([#20847](vitejs/vite#20847)) ([24a61a3](vitejs/vite@24a61a3))
- **deps:** update all non-major dependencies ([#20855](vitejs/vite#20855)) ([788a183](vitejs/vite@788a183))
- **deps:** update artichokie to 0.4.2 ([#20864](vitejs/vite#20864)) ([e670799](vitejs/vite@e670799))
- **dev:** skip JS responses for document requests ([#20866](vitejs/vite#20866)) ([6bc6c4d](vitejs/vite@6bc6c4d))
- **glob:** fix HMR for array patterns with exclusions ([#20872](vitejs/vite#20872)) ([63e040f](vitejs/vite@63e040f))
- keep ids for virtual modules as-is ([#20808](vitejs/vite#20808)) ([d4eca98](vitejs/vite@d4eca98))
- **server:** drain stdin when not interactive ([#20837](vitejs/vite#20837)) ([bb950e9](vitejs/vite@bb950e9))
- **server:** improve malformed URL handling in middlewares ([#20830](vitejs/vite#20830)) ([d65a983](vitejs/vite@d65a983))

##### Documentation

- **create-vite:** provide deno example ([#20747](vitejs/vite#20747)) ([fdb758a](vitejs/vite@fdb758a))

##### Miscellaneous Chores

- **deps:** update rolldown-related dependencies ([#20810](vitejs/vite#20810)) ([ea68a88](vitejs/vite@ea68a88))
- **deps:** update rolldown-related dependencies ([#20854](vitejs/vite#20854)) ([4dd06fd](vitejs/vite@4dd06fd))
- update url of `create-react-app` license ([#20865](vitejs/vite#20865)) ([166a178](vitejs/vite@166a178))
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 this pull request may close these issues.

4 participants