useAsync.run hands an overtaken answer back to nobody (#941) #947
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/useasync-overtaken"
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?
Closes #941, the follow-up to #932.
The bug:
useAsynckept an overtaken answer out of its own state, butrun()still resolved with it. So a caller that writes the result into its own state could draw a stale poll over a newer answer, as #932 did on the session page. The callers affected:useRead(the Review tab);PickedFold;The fix:
run()resolves toundefinedonce a newer run, orreset(), has overtaken it. Callers already readundefinedas "nothing to draw".Audit: I checked the other result-consuming callers in #941. None needs an overtaken run's answer: the concurrent ones ignore the result, and saves act on the newest run's answer.
Tests: two in
useAsync.test.jsx. Both fail on main's hook and pass here. The full vitest suite passes (2758) and eslint shows 0 errors.Changelog:
changelog.d/941-useasync-overtaken.fixed.md.🤖 Generated with Claude Code