Barcode scanner hangs on mobile — SW blocks AbortController timeout #66

Open
opened 2026-06-02 22:43:43 +00:00 by shawn · 0 comments
Owner

Root cause: Service Worker interception of API GET requests combined with AbortController creates a known browser bug — the abort signal does not propagate through the SW layer, causing fetch() to hang indefinitely on mobile Chrome/Safari.

Fix (commit 52f8016):

  1. Replaced AbortController in api() with Promise.race + setTimeout
  2. Modified SW to bypass all API requests entirely
  3. Added explicit MediaStream track stopping in stopScanning()
  4. Added 200ms yield point between camera stop and API call
  5. Added outer try/catch safety net in handleBarcode()
  6. Bumped SW cache to v11

Already done in previous commits: Scan New button after scan results (dd4744d), OCR serial suffix matching (c8ffab2).

**Root cause:** Service Worker interception of API GET requests combined with AbortController creates a known browser bug — the abort signal does not propagate through the SW layer, causing fetch() to hang indefinitely on mobile Chrome/Safari. **Fix (commit 52f8016):** 1. Replaced AbortController in api() with Promise.race + setTimeout 2. Modified SW to bypass all API requests entirely 3. Added explicit MediaStream track stopping in stopScanning() 4. Added 200ms yield point between camera stop and API call 5. Added outer try/catch safety net in handleBarcode() 6. Bumped SW cache to v11 **Already done in previous commits:** Scan New button after scan results (dd4744d), OCR serial suffix matching (c8ffab2).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shawn/canteen-asset-tracker#66