Commit c7e6481
authored
fix(cli): read stdin on demand (CLI-2223) (#6450)
## TL;DR
follow-up to #6290 Piped answers past the 1024th line were dropped.
stdin is now read one chunk at a time as prompts ask for it, so nothing
is dropped and the rest stays in the pipe...
## what was biting?
Bun reads a pipe as fast as it fills and cannot be paused, so #6290
drained it into a queue of 1024 lines to stop
`yes | supabase db push` from eating memory.
Anything past 1024 lines fell off the queue and those prompts took their
default...
## why this approach is better?
A file stream over fd 0 honours backpressure, so there is no queue and
no cap.
Memory is bounded the same way Go's `bufio.Scanner` did it: a line over
64 KiB ends line reading and every prompt from then on takes its
default...
## ref:
- adds onto issue: #6287
- extends: #62901 parent d35e892 commit c7e6481
6 files changed
Lines changed: 525 additions & 162 deletions
File tree
- apps/cli/src
- legacy/commands
- encryption/update-root-key
- logout
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
24 | | - | |
| 22 | + | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | | - | |
| 26 | + | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
0 commit comments