useAsync.run hands an overtaken answer back to its caller #941

Closed
opened 2026-09-29 19:11:12 +00:00 by claude-bot · 1 comment
Collaborator

This is the follow-up to #932, fixed there only in useSessionData.

The bug: useAsync keeps an overtaken answer out of its own state, but run() still resolves with it. Any caller that writes the result into its own state can therefore draw a stale answer over a newer one.

Affected callers: the ones that write the result themselves.

  • pages/session/useRead.js: the Review tab's reads, which are polled and re-read after actions;
  • PickedFold.jsx;
  • the retry buttons in NotesPanel, ConfirmedView, PencilledView and VoteView.

The fix, in the hook: run() resolves to undefined when a newer run, or reset(), has overtaken it. Callers already treat undefined as "nothing to draw".

Audit of the other result-consuming callers:

  • None of them needs an overtaken run's result. The concurrent ones (TestTheBot del.run(id), Sessions act.run(...)) ignore the result.
  • Saves that check ok (forms.jsx, EmailStop, EmailAnswer, Notifications) act on the newest run's answer instead.
This is the follow-up to #932, fixed there only in `useSessionData`. **The bug:** `useAsync` keeps an overtaken answer out of its own state, but `run()` still resolves with it. Any caller that writes the result into its own state can therefore draw a stale answer over a newer one. **Affected callers:** the ones that write the result themselves. - `pages/session/useRead.js`: the Review tab's reads, which are polled and re-read after actions; - `PickedFold.jsx`; - the retry buttons in `NotesPanel`, `ConfirmedView`, `PencilledView` and `VoteView`. **The fix, in the hook:** `run()` resolves to `undefined` when a newer run, or `reset()`, has overtaken it. Callers already treat `undefined` as "nothing to draw". **Audit of the other result-consuming callers:** - None of them needs an overtaken run's result. The concurrent ones (`TestTheBot` `del.run(id)`, `Sessions` `act.run(...)`) ignore the result. - Saves that check `ok` (`forms.jsx`, `EmailStop`, `EmailAnswer`, `Notifications`) act on the newest run's answer instead.
Author
Collaborator

Fixed in #947 (merged 2026-09-30, 8358a648). run() now resolves to undefined once a newer run or a reset() overtakes it, so no caller can draw a stale answer. Two new tests fail on the old hook.

Fixed in #947 (merged 2026-09-30, `8358a648`). `run()` now resolves to `undefined` once a newer run or a `reset()` overtakes it, so no caller can draw a stale answer. Two new tests fail on the old hook.
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
rbrooks/Quest-Board#941
No description provided.