pyronear / pyronear/pyro-annotator
Localize editor: fast double-commit races the annotation refetch and POSTs a duplicate
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 2
Description
Found while reviewing #386, but the hazard predates it.
Mechanism
modalContext.existingAnnotation on LocalizeAlertPage is derived from the react-query cache, and saveDetection.onSuccess only invalidates — the value stays null until the refetch lands. saveDetectionReview branches create-vs-patch on it, so two commits in quick succession on a frame with no annotation yet both take the POST branch. The second POST hits uq_detection_annotation_detection_id and the annotator sees a "Failed to save frame — try again" toast for a save that actually succeeded.
Nothing debounces or disables between the two writes: useMutation.mutate has no in-flight guard and isSaving only feeds the "Saving…" label.
Triggers
Any two fast commits on an undecided frame: double-press of Delete/Backspace (auto-repeat is already dropped, a deliberate double press is not), two quick candidate clicks on the rail, and since #386 a double-press of P.
Possible directions
- An in-flight guard on the editor's commit path (drop commits while one is pending), or
- upsert semantics on the single-annotation POST (the bulk endpoint already guards this case), or
- an optimistic cache write so the second commit sees the annotation and PATCHes.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at LocalizeAlertPage and trace saveDetection.onSuccess, saveDetectionReview, and the useMutation.mutate call through the editor commit path. Reproduce two fast commits on an undecided frame and compare the available guard, upsert, and optimistic-cache directions. Done means the duplicate request no longer produces a failure toast when the first save succeeded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 48/100