Skip to content

feat(forms): #32 flush the offline form queue on Firefox/Safari (no SyncManager)#144

Merged
TortoiseWolfe merged 1 commit into
mainfrom
feat/32-forms-offline-flush
Jun 6, 2026
Merged

feat(forms): #32 flush the offline form queue on Firefox/Safari (no SyncManager)#144
TortoiseWolfe merged 1 commit into
mainfrom
feat/32-forms-offline-flush

Conversation

@TortoiseWolfe

Copy link
Copy Markdown
Owner

Closes #32.

What

The contact-form offline queue relied solely on the Background Sync API (registerBackgroundSync), which returns false on Firefox/Safari — so queued submissions there never auto-sent. Adds a foreground fallback:

  • background-sync.tsstartFormQueueFallback() installs online + visibilitychange listeners that processQueue() when SyncManager is absent (no-op where it's supported, so no double-processing). Mirrors payments/connection-listener.ts; returns a cleanup fn; drains anything already queued on start.
  • useWeb3Forms — starts the fallback on mount and exposes retryQueue() for a manual retry affordance, refreshing the count after a flush.

Scope note

True app-closed background sync remains impossible on Firefox/Safari — there is no SyncManager there, and a closed tab can't run JS. That's a browser limitation, not an app gap. This covers the realistic case: tab open, connection returns or tab refocused → queue drains. The storage-warning sub-item is already covered by the #134 storage-quota work.

Verification

  • type-check / lint / structure (109/109) / build green.
  • 3 new startFormQueueFallback tests (no-op when supported; installs+cleans up listeners; flushes on online); existing useWeb3Forms (17) + ContactForm (33) suites pass after mock updates.

🤖 Generated with Claude Code

…yncManager)

The contact-form offline queue relied solely on the Background Sync API
(registerBackgroundSync), which returns false on Firefox/Safari — so queued
submissions there never auto-sent. Add a foreground fallback:

- background-sync.ts: startFormQueueFallback() installs online + visibilitychange
  listeners that processQueue() when SyncManager is absent (no-op where it's
  supported, so no double-processing). Mirrors payments/connection-listener.ts;
  returns a cleanup fn. Drains anything already queued on start.
- useWeb3Forms: starts the fallback on mount and exposes retryQueue() for a
  manual retry affordance, refreshing the queue count after a flush.

True app-closed background sync remains impossible without SyncManager; this
covers the realistic case (tab open, connection returns / tab refocused).

Tests: 3 for startFormQueueFallback (no-op when supported; installs+cleans up
listeners; flushes on online). Existing useWeb3Forms + ContactForm mocks updated
for the new exports/return field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TortoiseWolfe TortoiseWolfe merged commit ea9a13e into main Jun 6, 2026
18 checks passed
@TortoiseWolfe TortoiseWolfe deleted the feat/32-forms-offline-flush branch June 6, 2026 15:11
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.

[Gap-Audit] 020 PWA Background Sync: Firefox/Safari fallback + retry UI + storage warnings

2 participants