fix(workspace-server): persist poll-mode canvas user message synchronously before queued 200 (internal#471, sibling of #1347) #1350
Merged
devops-engineer
merged 2 commits from 2026-05-16 15:49:31 +00:00
fix/canvas-user-message-poll-mode-sync-persist into main
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
| 1d29e9ea24 |
fix(handlers): prevent poll-mode sync-persist test from hanging CI
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 23s
CI / Detect changes (pull_request) Successful in 26s
E2E API Smoke Test / detect-changes (pull_request) Successful in 32s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 34s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 51s
Harness Replays / detect-changes (pull_request) Successful in 35s
E2E Chat / detect-changes (pull_request) Successful in 44s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 43s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 23s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 35s
qa-review / approved (pull_request) Failing after 33s
gate-check-v3 / gate-check (pull_request) Failing after 39s
security-review / approved (pull_request) Failing after 36s
sop-checklist / all-items-acked (pull_request) Successful in 36s
sop-tier-check / tier-check (pull_request) Successful in 29s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 2m11s
Harness Replays / Harness Replays (pull_request) Successful in 7s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 28s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 1m28s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 1m48s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 26s
CI / Python Lint & Test (pull_request) Successful in 8m21s
E2E Chat / E2E Chat (pull_request) Failing after 7m10s
CI / Platform (Go) (pull_request) Successful in 12m49s
CI / Canvas (Next.js) (pull_request) Successful in 12m54s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 13m5s
audit-force-merge / audit (pull_request) Successful in 36s
sqlmock.ExpectationsWereMet() hangs indefinitely when the expected INSERT mock never fires. If the production code ever regresses to goAsync (pre-fix shape), the handler returns before the INSERT fires, the mock never fires, and ExpectationsWereMet() blocks for the full test/-suite timeout — wedging the CI run with no diagnostic. Fix: check expectations in a goroutine with a 2s hard timeout. When the mock has fired (synchronous production code), ExpectationsWereMet() returns <1ms and the select fires the `case err := <-expectDone` arm. When the mock has NOT fired (async regression), the 2s timeout fires and the test fails with a clear message instead of hanging. Also reduce insertDelay from 150ms → 50ms. 50ms is ~50× the normal INSERT latency and sufficient to prove synchronous blocking; the larger value was adding unnecessary suite-level wall-clock under -race detection, where mock delays are amplified by the instrumenter's goroutine overhead. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
|||
| a92beb5d49 |
fix(workspace-server): persist poll-mode canvas user message synchronously before queued 200
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 25s
CI / Detect changes (pull_request) Successful in 22s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 53s
E2E API Smoke Test / detect-changes (pull_request) Successful in 30s
E2E Chat / detect-changes (pull_request) Successful in 37s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 38s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 35s
Harness Replays / detect-changes (pull_request) Successful in 38s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 40s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 50s
gate-check-v3 / gate-check (pull_request) Successful in 57s
qa-review / approved (pull_request) Successful in 51s
security-review / approved (pull_request) Failing after 48s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 2m15s
sop-tier-check / tier-check (pull_request) Successful in 33s
CI / Platform (Go) (pull_request) Failing after 10m44s
CI / Canvas (Next.js) (pull_request) Failing after 10m20s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / Python Lint & Test (pull_request) Successful in 9m18s
CI / all-required (pull_request) Failing after 8m57s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 31s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 19s
Harness Replays / Harness Replays (pull_request) Successful in 21s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 3m15s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 5m0s
E2E Chat / E2E Chat (pull_request) Failing after 12m29s
sop-checklist / all-items-acked (pull_request) acked: 3/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +1 — body-unfilled: comprehensive-testing, local-postgres-e2
Sibling of #1347/internal#470 — the POLL-mode arm of the canvas
user-message data-loss bug Hongming reported ("i sometimes lose my own
message when i exit chat", 2026-05-16).
Hongming's tenant is entirely poll-mode (4 external workspaces, no URL —
verified empirically: every workspace returns the {delivery_mode:poll,
status:queued} short-circuit envelope), so #1347 (push-mode only,
persists AFTER the poll short-circuit) structurally cannot cover his
reported case. #1347's "poll-mode was never affected" framing is
overstated: logA2AReceiveQueued's durable activity_logs INSERT ran
inside h.goAsync(...) — a detached goroutine with no happens-before
barrier against the synthetic {status:queued} 200. The canvas sees the
send acknowledged while the row may still be racing; a workspace-server
restart / deploy / OOM / EC2 hibernation between the 200 and the
goroutine's commit loses the message permanently (chat-history reads
activity_logs; missing row = message gone on reopen). No fallback
either, unlike push-mode's legacy-INSERT path.
Fix: make the poll-mode ingest persist SYNCHRONOUS — committed before
the queued 200 — on a context.WithoutCancel context (parity with
persistUserMessageAtIngest). Best-effort preserved (LogActivity
logs+swallows INSERT errors, never blocks the send). Post-commit
broadcast still fires inside LogActivity (a missed WS event is not data
loss; the durable row is the truth chat-history re-reads on reopen).
TDD: a2a_poll_ingest_persist_test.go — deterministic RED (queued 200
returned in ~0.5ms, before the 150ms INSERT → DATA LOSS) → GREEN after
fix. Full internal/handlers + internal/messagestore suites green; vet
clean.
Refs: molecule-ai/internal#471 (tracking), molecule-ai/internal#470 (push-mode sibling, PR #1347)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|