Skip to content

Migrate background-sync off the deprecated utils/offline-queue (shared IndexedDB name) #89

Description

@TortoiseWolfe

Split out of #82, where it was mistakenly listed as a straight deletion.

Why it is not a deletion

src/utils/offline-queue.ts is marked @deprecated and superseded by src/lib/offline-queue/form-adapter.ts, but it is still live in production:

/contact  ->  ContactForm  ->  useWeb3Forms.ts:15  ->  utils/background-sync.ts:11  ->  utils/offline-queue.ts

background-sync.ts pulls getQueuedItems, removeFromQueue and updateRetryCount from it.

Why it needs care rather than an import swap

useWeb3Forms already straddles both systems — line 14 writes via addToQueue from @/lib/offline-queue, line 15 registers background sync, which reads through the old module.

Both implementations target the same IndexedDB database name, 'OfflineFormSubmissions' (src/utils/offline-queue.ts:21, src/lib/offline-queue/form-adapter.ts:37). So they are not two independent stores that can be swapped — they are two implementations pointed at one database, and whether their schemas and version numbers are equivalent is unverified.

Getting this wrong risks queued-but-unsent contact form submissions on real users' devices.

Work

  • Diff the two schemas: object store names, key paths, indexes, version numbers, and the record shape each writes
  • Decide whether a migration is needed or the stores are already compatible
  • Point background-sync.ts at @/lib/offline-queue
  • Test with a populated queue from the OLD implementation, not just an empty one — that is the case that can lose data
  • Then delete src/utils/offline-queue.ts and its .browser.test.ts, and drop the vi.mock at src/hooks/useWeb3Forms.test.ts:23

Already done

The module-scope console.warn is now dev-only (5ef426b). It had been printing in the console of every visitor to /contact. The debt is no longer user-visible, which lowers the urgency but does not remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions