You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Chat attachment 10-file cap can be bypassed when rapid sequential uploads overlap in-flight #2026
Rapidly drop two batches of 6 files each in quick succession (before the first batch finishes uploading).
The slot-count check runs at the start of `uploadFiles` and reads `attachmentsRef.current.length`, which only reflects settled uploads — not in-flight ones.
Both calls see `length = 0` and each approve their full 6-file batch.
Both batches upload in parallel; the chat ends up with 12 attached files, exceeding the 10-file cap.
Expected
Each subsequent `uploadFiles` call should account for in-flight uploads and reject overflow files before they are uploaded.
Actual
The slot check at line 230 reads `attachmentsRef.current.length`, which is backed by React state updated only when each individual upload completes (line 335: `setAttachments((prev) => [...prev, attachment])`). Files still uploading are tracked in `uploadingFiles` (string IDs) but their count is never subtracted from the available slots. Two rapid drops (or paste + drop) before any upload settles both see the stale count and both pass the guard, resulting in up to 2 × 10 = 20 uploads.
`services/platform/app/features/chat/hooks/use-convex-file-upload.ts:283` — in-flight IDs added to `uploadingFiles` string array, never counted against slots
`services/platform/app/features/chat/hooks/use-convex-file-upload.ts:335` — `setAttachments` called only after successful upload (too late for the guard)
Fix: add an `inFlightCountRef` that is incremented before upload starts and decremented on settle, then use `attachmentsRef.current.length + inFlightCountRef.current` as the slot-check denominator. Alternatively, gate the slot check under an async lock/semaphore. The deduplication and total-size checks have the same stale-ref exposure.
Activity
fix(platform): count in-flight uploads against chat attachment cap (#…
fix(platform): count in-flight uploads against chat attachment cap (#…