fix: await live SSE protocol writes before terminal done event#361
Merged
Conversation
The live /api/check/stream path awaited only the terminal `done` write (#303) while protocol events were still fire-and-forget. Under Hono’s streamSSE lifecycle those frames can be dropped before the client reads them, leaving skeleton cards on the progressive /check page. Collect pending protocol writeSSE promises, flush them with Promise.all, then emit `done`. Add a cache-miss regression test that drains the body. Co-authored-by: schmug <schmug@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
dmarcheck | ba44b90 | May 24 2026, 03:01 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
On cache-miss
/api/check/streamscans, protocol SSE events were emitted with unawaitedstream.writeSSE()calls. The terminaldoneevent was fixed in #303, but protocol frames could still be dropped when the stream closed—users could see the grade header/footer while protocol cards stayed on skeleton placeholders.Root cause
Same race as #303: Hono
streamSSEcan close before fire-and-forget writes flush. Onlydonewas awaited after that fix.Fix
writeSSEpromises duringscanStreamingcallbacksawait Promise.all(protocolWrites)before emittingdoneValidation
npm run lintnpm run typechecknpm test(1051 tests)