A page appeared to stay stuck on the first item opened, while the system quietly created extra work assignments in the background.
The bug looked like stale UI state at first. The deeper problem was that a request which changed server state was being treated like a cacheable read.
The failure pattern
The frontend used a data-fetching query for an endpoint that claimed the next available item. That endpoint did more than retrieve data: it created an assignment and locked the item for the current user.
Because the request was cached, revisiting the screen could immediately reuse the first response. A background refetch could then run the POST again, creating another assignment even though the UI continued displaying the original item.
There was a second issue: changing only a query-string parameter did not remount the page component. Local state still held the first active item, so the URL and the visible content could disagree.
The fix
The repair had two coordinated parts.
On the backend, the open queue now checks for the caller's oldest in-progress assignment before claiming anything new. If unfinished work exists, the same assignment is returned. A new assignment is created only when the caller has no active work.
On the frontend, the state-changing POST was moved from a cached query to an explicitly triggered mutation. The Annotator view is also remounted when its target changes, so local state cannot leak from one page to another. Sign-out and failed token refreshes clear the server-state cache as well.
After an item is approved or released, navigation returns to a clean queue URL so the next request represents the user's actual next action.
What this reinforced
- Use queries for reads and mutations for operations with server-side effects.
- Treat every POST that creates, locks, charges, sends, or claims something as non-cacheable unless it is deliberately idempotent.
- Keep the server safe even when the client retries, refreshes, or behaves unexpectedly.
- Test browser history and query-parameter navigation, not just full-page loads.
- React development behavior can expose real duplicate-request bugs; it should not be dismissed as noise.
The most useful debugging question was simple: does this request merely read state, or does it create state? Once that distinction was made explicit, both the frontend and backend fixes became straightforward.
This lesson generalizes well beyond assignment queues: checkout flows, reservation systems, job dispatch, email sending, and any UI action where a repeated request has consequences all need the same discipline.
Top comments (0)