Files
apes-sidebar/tests
NolanHo 6497046c9e fix(search-engines): settle streamLines on close, propagate fd dirs-run failures (#883)
streamLines settled its promise on the child's 'exit' event. Node fires
'exit' the moment the process dies, while the stdout pipe may still hold
undrained data — under host load the exit event can win that race and the
promise resolved with a still-empty lines array. fd's second --type d run
was the common victim (both children race, the match run usually drains
first), so the observable signature was matches intact with dirs: [] —
directory hits silently degraded into open-as-file errors, the exact
error surface #801 fixed, now intermittent.

Settlement moves to 'close' (process dead AND stdio drained, so every
readline line event has fired). The truncation kill, the timeout and the
spawn-error paths keep their semantics: whichever finish() ran first
sets the closed flag and the close handler is idempotent. The --version
probe keeps 'exit' — its stdio is 'ignore', the exit code is the only
signal it reads.

The fd branch also no longer swallows the directory run's failure: the
.catch(() => empty dir list) is deleted, so a rejection now reaches
runEngine's existing broken-marking and this one search falls back to
the plain walk — symmetric with the main run, where the old catch
degraded every failure into an invisible "zero directories".

Evidence: on an fd-equipped Linux host the real-engine suite reproduced
7/30 runs on clean dev (signature constant), 0/30 after the one-line
close change; upstream CI never saw it (ubuntu lane has no fd; ci-windows
runs serially). Two deterministic cases now pin the contracts through the
new spawner hook (scripted PassThrough children replay the racy event
order directly); each was verified red by temporarily reverting the
corresponding half of the fix.
2026-10-06 10:50:51 -07:00
..
2026-09-09 11:15:30 +08:00