Skip to content

bug: PouchDB "unknown_error" on iOS Safari prevents saving documents #3832

@sleidig

Description

@sleidig

Sentry Issue

AAM-DIGITAL-6RN — 3 occurrences since 2026-03-24, all on iPhone / Mobile Safari

Error

unknown_error: Database encountered an unknown error

PouchDB's generic catch-all error (HTTP 500) when it encounters an IndexedDB operation failure it can't categorize.

Affected Users / Environment

Field Value
Device iPhone (all occurrences)
Browser Mobile Safari 18.6, 26.3, 26.4
OS iOS 18.6.2, 18.7
Release ndb-core@3.74.0
Pages /mentor/:id/, /child/:id/

Analysis

This is a PouchDB + iOS Safari IndexedDB reliability issue. iOS Safari's IndexedDB implementation can sporadically fail:

  • Storage pressure — iOS aggressively evicts IndexedDB data when storage is low
  • Background/foreground transitions — iOS Safari may interrupt IndexedDB transactions when the app is backgrounded
  • IndexedDB transaction aborts — some iOS versions have bugs in their IndexedDB implementation that can abort transactions unexpectedly

All events occur shortly after a completed sync (~10-20 seconds), suggesting the error is triggered during a subsequent PouchDB operation — likely the next live sync cycle, the changes feed, or a user-initiated save.

Error Propagation

When IndexedDB fails, PouchDB's internal error can escape outside the normal Promise chain (via aborted transactions / callbacks), bypassing all application-level try/catch. The error reaches Angular's global error handler as unhandled.

Save path (entity form → EntityFormService.saveChanges()EntityMapperService.save()PouchDatabase.put()) has proper try/catch and shows the user a "Could not save" alert. However, if the IndexedDB is in a broken state, subsequent PouchDB operations (live sync, changes feed) also fail and are not always caught.

Impact on Users

When IndexedDB is in a bad state:

  1. Saves failPouchDatabase.put() throws, user sees a "Could not save..." alert
  2. Sync fails — background sync can't read/write to local storage
  3. The database may partially recover on subsequent attempts if iOS releases IndexedDB

Possible Mitigations

  1. Better user guidance: Detect unknown_error from PouchDB and show a helpful message suggesting the user reload the page or clear browser data
  2. Temporary remote-only fallback: If local PouchDB operations repeatedly fail, switch to remote-only mode (already supported via isInRemoteOnlyMode) so users can still save directly to the server
  3. Test with newer indexeddb adapter: Production defaults to use_indexeddb_adapter: false (legacy idb adapter). The newer adapter may handle iOS error cases more robustly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Triage / Analysis

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions