Skip to content

[T3352] FIX: guard letter submit against double-click race - #357

Merged
Danielgergely merged 1 commit into
18.0from
T3352-letter-progress-race-18
Aug 4, 2026
Merged

[T3352] FIX: guard letter submit against double-click race#357
Danielgergely merged 1 commit into
18.0from
T3352-letter-progress-race-18

Conversation

@Danielgergely

Copy link
Copy Markdown
Member

-FIX: Guard _onSubmitLetter against double submission + error.

-FIX: Guard _onSubmitLetter against double submission + error.
@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex produced a proof for the posted P1 finding and linked it to the corresponding review comment for finding details.
  • T-Rex validated the in-flight create_generator calls by reproducing two calls, send and save_draft, both using _isSubmitting: true and an empty generator_id, in the file my_compassion/static/src/js/my2_new_letter.js:316-330, where autosave lacks an _isSubmitting/shared-operation guard and interacts with the submit guard at lines 63-67.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (2)

  1. my_compassion/static/src/js/my2_new_letter.js, line 316-330 (link)

    P1 Autosave bypasses submission lock

    When a user edits a new letter and submits before the pending five-second autosave fires, _autoSaveDraft bypasses _isSubmitting and calls _createGenerator concurrently. Both requests can read the same empty or stale generator_id, causing duplicate generator records for a new letter or conflicting last-write-wins updates to an existing draft.

  2. General comment

    P1 Autosave can race an active letter submission

    • Bug
      • A five-second autosave timer can invoke _autoSaveDraft while _onSubmitLetter is awaiting _createGenerator. Autosave does not inspect _isSubmitting or share a mutual-exclusion mechanism, so it sends another create_generator RPC.
    • Cause
      • _isSubmitting is set and checked only by _onSubmitLetter; _autoSaveDraft independently collects the form snapshot and calls _createGenerator. The form input is updated with the server generator ID only after an RPC resolves.
    • Fix
      • Coordinate autosave and submission with a shared in-flight guard/lock (or skip/cancel autosave while _isSubmitting is true) and ensure a pending autosave is cancelled or deferred when submission begins.

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "[T3352] FIX: guard letter submit against..." | Re-trigger Greptile

@Danielgergely
Danielgergely merged commit 441ad52 into 18.0 Aug 4, 2026
2 checks passed
@Danielgergely
Danielgergely deleted the T3352-letter-progress-race-18 branch August 4, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant