mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5897] Flaky e2e: live-stream-row test times out in cleanup deleting its chat (unguarded delete racing client stream teardown) #3254
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3254
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Sep 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5897
Originally assigned to: @SpicyMarinara on GitHub.
What happened
On PR #5894's CI (run 34052213005, job
desktop-chromium 1/3), the testediting the preceding Roleplay message keeps one live stream row(e2e/core-flows.e2e.ts:7100) failed once with:The failure is in the test's
finallycleanup, not its assertions. The PR's changes (Mari workspace sandbox) don't touch anything on this path, and the same suite passed on the commit before; a rerun of the shard was started. Filing this so the flake shape is on record — one observation so far.Why this test's cleanup is fragile by construction
Tracing the test end to end turned up a cleanup contract that guarantees a race every run; the only question is whether the race costs enough time to blow the budget.
e2e/core-flows.e2e.ts:7133fulfills**/api/generatewith the entire SSE body in one buffered response viapage.route. The server never registers a generation for this chat — there is no server-side stream at any point.streamingSpeed=55(55 visible chars/second —packages/client/src/hooks/use-generate.ts:1554) over a ~4,500-char body, which needs ~82 seconds. The Playwright per-test budget is 60s (playwright.config.ts:33). So the typewriter cannot finish before the test ends, by design — the stream row is always live at teardown.:7190is actually a Stop click (packages/client/src/components/chat/ChatInput.tsx:2162— the button swaps tostopGenerationwhile streaming), which fires a local abort plus an un-awaitedPOST /api/generate/abort(packages/client/src/stores/chat.store.ts:144).page.request.delete('/api/chats/…')— no.catch, no timeout guard, no settle-first. It races the in-flight abort POST and the client teardown with whatever budget the test has left.The immediately preceding test ("rewrite-scroll",
:7094-7096) shares the identical stop-click-then-bare-delete pattern and is presumably one bad day away from the same failure.What it is not
To rule out the obvious suspect:
DELETE /api/chats/:id(packages/server/src/routes/chats.routes.ts:1785) has no wait path. It aborts any active generation fire-and-forget (:1811), takes no per-chat lock shared with generation, and there is no 60-second constant anywhere on the route. The abort is fully wired down to the provider's fetch/reader cancel. So this is not "delete waits on the stream" — server-side, there was no stream to wait on. The remaining candidate mechanisms are all environmental (a slow file-store flush/transaction ahead of the delete's transaction, or CI runner starvation), which is exactly what a cleanup with no timeout guard is defenseless against.Suggested fix (test-side)
Sibling tests already model the right contract:
updateLiveReasoningState(page, chat.id, "stop")at:6993, then a delete with.catch).bestEffortDelete(:228) wraps cleanup deletes in a 5s timeout + catch, so cleanup can never consume the test budget.Applying either (or both) to this test and its twin at
:7094-7096makes the cleanup unable to fail the test regardless of what the delete does. Not started on a fix — just recording the diagnosis.Noticed in passing (server-side, separate concerns)
Two small gaps in the chat-delete route surfaced while tracing, neither the cause of this flake; noting them here so they aren't lost, happy to split them into their own issues if wanted:
DELETE /api/chats/:idaborts onlyactiveGenerations, notactiveAgentRuns— the dedicatedPOST /api/generate/abortaborts both (packages/server/src/routes/generate.routes.ts:10726). A generation that has moved into its agent tail (moveToActiveAgentRuns,:942) survives chat deletion un-aborted.activeGenerationsmap entry immediately (chats.routes.ts:1812), which the abort route deliberately avoids — its comment (generate.routes.ts:10765) calls immediate deletion a same-chat re-registration race.Prior art checked
No existing issue or PR mentions this test, a chat-delete hang, or
apiRequestContext.delete(searched issues + PRs; read the flake ledgers #5589, #5633, #5642 and their fix PRs — all cover different tests). Closest relative is #5254 (closed): a different core-flows test whose cleanup DELETE silently 409'd — same bug class (e2e chat-deletion cleanup contract), different test and failure shape.@shoaibyazdani commented on GitHub (Sep 6, 2026):
e2e/core-flows.e2e.ts:7100looks like where this lives — walking through the bug shape, the symptom is: flaky e2e: live-stream-row test times out in cleanup deleting its chat (unguarded….Can put together a PR against this branch if it's still open.
—
Filed by @shoaibyazdani — happy to be un-assigned if you prefer.
@kolacheee commented on GitHub (Sep 6, 2026):
@shoaibyazdani thank you for the offer, however, @SpicyMarinara's presence is still intermittent at this time due to vacation, so it's better if outside contributors don't submit PRs at this time. SpicyMarinara is the only one able to merge PRs from outside contributors, unfortunately.
@SpicyMarinara commented on GitHub (Sep 7, 2026):
Owner: @SpicyMarinara; Codex is taking this in draft issue-sweep PR #5929. Existing issue-linked branches and open/draft PRs were checked before starting. I will verify the reported behavior against current staging and keep the fix and regression proof focused.
@SpicyMarinara commented on GitHub (Sep 7, 2026):
Fixed in #5929, merged into staging as
4f67630e6. Stream cleanup now stops the test stream before deleting its chat; the full regression matrix passed.