Bug: ticking a task fails with "Couldn't change that task" when the server answers 503 not_saved_yet (retryable); tasks-tick flakes under --workers=2 #1179

Open
opened 2026-11-15 23:19:46 +00:00 by kayg · 1 comment
Owner

Found by the stability lane while looking at why tasks-tick.spec.ts (tests 49, 61, 72) fails about 7 % of the time under --workers=2 --repeat-each=10 (chromium-1440, dev-02: 6 failed / 74 passed on dev 42c219afd), and 1 in 240 alone.

What the trace shows

Failing repeat, page network log: tasks.set-status {"id":…,"status":"done","version":178} answered 503 with
{"error":{"code":"not_saved_yet","message":"Not saved yet. Trying again.","request_id":…,"retryable":true}}, 230 ms after the click. Nothing else is sent: apps/web/src/tasks/status.ts send() retries only a block_changed refusal inside the 3 s window after this device's own write, so the 503 propagates, setStatus drops pending[id] (the box un-ticks) and shows the toast "Couldn't change that task". The test then waits 20 s for done and fails.

The server's 503 is ErrorCode::NotSavedYet (crates/core/src/error.rs: status 503, retryable: true, "Not saved yet. Trying again."). One source is Home::room_meta_lock (crates/notes/src/meta.rs): "metadata publication busy; retry", returned when a publication is in progress for more than 25 ms. A task ticked right after it was made (or while another worker's writes publish) hits it.

Cause

A product bug, not a test race: the server says "try again" and the Tasks client treats it as a refusal. A person who ticks a task while the server is publishing sees the box un-tick and an error toast instead of the tick going through a moment later.

Fix (PR to follow)

send() also tries again on not_saved_yet, spaced AGAIN_MS, for at most 10 s (a set-status to the same status is idempotent). Every other refusal still stands. Regression spec: a page.route answers the first tasks.set-status with that 503, and the tick must still end done, with no failure toast.

Found by the stability lane while looking at why `tasks-tick.spec.ts` (tests 49, 61, 72) fails about 7 % of the time under `--workers=2 --repeat-each=10` (chromium-1440, dev-02: 6 failed / 74 passed on dev `42c219afd`), and 1 in 240 alone. ## What the trace shows Failing repeat, page network log: `tasks.set-status` `{"id":…,"status":"done","version":178}` answered **503** with `{"error":{"code":"not_saved_yet","message":"Not saved yet. Trying again.","request_id":…,"retryable":true}}`, 230 ms after the click. Nothing else is sent: `apps/web/src/tasks/status.ts` `send()` retries only a `block_changed` refusal inside the 3 s window after this device's own write, so the 503 propagates, `setStatus` drops `pending[id]` (the box un-ticks) and shows the toast "Couldn't change that task". The test then waits 20 s for `done` and fails. The server's 503 is `ErrorCode::NotSavedYet` (`crates/core/src/error.rs`: status 503, `retryable: true`, "Not saved yet. Trying again."). One source is `Home::room_meta_lock` (`crates/notes/src/meta.rs`): "metadata publication busy; retry", returned when a publication is in progress for more than 25 ms. A task ticked right after it was made (or while another worker's writes publish) hits it. ## Cause A product bug, not a test race: the server says "try again" and the Tasks client treats it as a refusal. A person who ticks a task while the server is publishing sees the box un-tick and an error toast instead of the tick going through a moment later. ## Fix (PR to follow) `send()` also tries again on `not_saved_yet`, spaced `AGAIN_MS`, for at most 10 s (a set-status to the same status is idempotent). Every other refusal still stands. Regression spec: a `page.route` answers the first `tasks.set-status` with that 503, and the tick must still end `done`, with no failure toast.
Author
Owner

Evidence for PR #1181 (head 766fb9d40), stability lane

Traces of failing tasks-tick repeats (--workers=2, chromium-1440, dev-02): page network log shows tasks.set-status answered 503 not_saved_yet (retryable) once, or 409 block_changed after 2.9 to 4.8 s (the task note's room still holds the save of the write that made the task); send() did not ask again, or its 3 s window was used up by the wait for the answer.
Red: f63390407 (503 spec) fails 3 / 3, f3c4f67b7 (409 spec) fails 3 / 3. Green: 3 / 3 and 5 / 5 at the fix commits.
tasks-tick.spec.ts --workers=2 --repeat-each=10, chromium-1440 (dev-02): dev 6 / 80 fail; with the 503 retry only 6 / 90; with the 409 early retry (window in seconds) 5 / 100; with asks counted (766fb9d40) 1 / 100; with #1180 added 1 / 100 (the one left: the server answering changed for more than 14 s, i.e. server latency under load).
Gates: svelte-check 0 errors, vitest 319, lint ok. tasks-tick + tasks-board --repeat-each=10 --workers=1: webkit-1440 159 / 160 (the one: tasks-board.spec.ts:56, the 5 s poll for Someday expired; the Someday path is two writes and I did not compare it with dev), webkit-390 100 / 100, chromium-390 98 / 100 (the two are the covered click of #1165, fixed by #1167).
Perf statement: error path of a refusal only.

## Evidence for PR #1181 (head `766fb9d40`), stability lane Traces of failing `tasks-tick` repeats (`--workers=2`, chromium-1440, dev-02): page network log shows `tasks.set-status` answered **503 `not_saved_yet`** (retryable) once, or **409 `block_changed`** after 2.9 to 4.8 s (the task note's room still holds the save of the write that made the task); `send()` did not ask again, or its 3 s window was used up by the wait for the answer. **Red:** `f63390407` (503 spec) fails 3 / 3, `f3c4f67b7` (409 spec) fails 3 / 3. **Green:** 3 / 3 and 5 / 5 at the fix commits. **`tasks-tick.spec.ts` `--workers=2 --repeat-each=10`, chromium-1440 (dev-02):** dev 6 / 80 fail; with the 503 retry only 6 / 90; with the 409 early retry (window in seconds) 5 / 100; with asks counted (`766fb9d40`) **1 / 100**; with #1180 added 1 / 100 (the one left: the server answering `changed` for more than 14 s, i.e. server latency under load). **Gates:** svelte-check 0 errors, vitest 319, lint ok. `tasks-tick` + `tasks-board` `--repeat-each=10` `--workers=1`: webkit-1440 159 / 160 (the one: `tasks-board.spec.ts:56`, the 5 s poll for Someday expired; the Someday path is two writes and I did not compare it with dev), webkit-390 100 / 100, chromium-390 98 / 100 (the two are the covered click of #1165, fixed by #1167). **Perf statement:** error path of a refusal only.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#1179
No description provided.