feat(forms): #32 flush the offline form queue on Firefox/Safari (no SyncManager)#144
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ts—startFormQueueFallback()installsonline+visibilitychangelisteners thatprocessQueue()when SyncManager is absent (no-op where it's supported, so no double-processing). Mirrorspayments/connection-listener.ts; returns a cleanup fn; drains anything already queued on start.useWeb3Forms— starts the fallback on mount and exposesretryQueue()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
startFormQueueFallbacktests (no-op when supported; installs+cleans up listeners; flushes ononline); existinguseWeb3Forms(17) +ContactForm(33) suites pass after mock updates.🤖 Generated with Claude Code