fix(sink): stop() waits for in-flight signals before returning #7

Merged
KofTwentyTwo merged 1 commits from feature/sink-stop-drains-in-flight into develop 2026-10-12 22:50:52 +00:00
1 Commits
Author SHA1 Message Date
james.maesandClaude Opus 5.5 23054f54f1 fix(sink): stop() waits for in-flight signals before returning
The drain thread could take a signal off the queue and still be writing
it when stop() flushed (an empty queue) and returned; the interrupt could
also land mid-write. A resolve submitted just before shutdown could be
lost. That is what failed SinkAndScheduleTest on the release/0.1 build.

stop() now ends the drain loop with a flag, joins the thread (up to 10 s,
interrupting only if it does not finish), then flushes what is left. The
drain poll is 200 ms so stop() returns promptly. New regression test fails
on the old code (3 of 4 runs) and passes on the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:48:46 -05:00