Commit f7c7d1d
committed
fix(ipfs): listen on 'close' so stderr drains before _spawnAsync rejects
Pulled the Promise wiring out of _spawnAsync into an exported
_gatherChildOutput so the race is unit-testable. Listen on 'close' (not
'exit'): Node guarantees 'close' fires after all stdio streams have
closed, so every stderr 'data' event has been delivered by the time we
build the rejection Error.
Why this matters: a fast-exiting child can deliver its exit signal
before its stderr drains. With the old 'exit' listener, _spawnAsync
rejected with errorMessage="". In startKuboNode the empty message
defeated the `error.message.includes("ipfs configuration file already
exists!")` suppression, turned a benign already-initialised repo into
"Failed to call ipfs init" — and because startKuboNode wraps an async
executor in `new Promise(...)`, that throw became an unhandledRejection
instead of propagating, hanging keepKuboUp() and letting the daemon
exit silently with code 0. That's the macos-latest CI failure on PR #47.
The regression test in test/kubo/gather-child-output.test.ts feeds a
fake EventEmitter the macOS event ordering (exit → data → close) and
asserts the rejection captures the stderr text. Cross-platform
deterministic, fails on the old 'exit' listener, passes on 'close'.1 parent 5094658 commit f7c7d1d
2 files changed
Lines changed: 61 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | | - | |
81 | | - | |
82 | 84 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments