super-productivity/src
John Costa 32dbc95ed9
fix(persistence): increase IndexedDB retry window for session-restart locks (#7220)
* fix(persistence): increase IndexedDB retry window for session-restart locks

On Linux desktop environments (especially Flatpak with autostart),
logging out and back in can leave stale LevelDB locks for 5-15+
seconds. The previous retry window (~3.5s) was too short to outlast
this, causing "Database Error - Cannot Load Data" on every
logout/login cycle.

Increase IDB_OPEN_RETRIES from 3 to 5 and IDB_OPEN_RETRY_BASE_DELAY_MS
from 500ms to 1000ms, giving a total retry window of ~31 seconds.

Fixes #7191

* fix: update stale retry timing comments to match new constants

* fix(persistence): gate long IDB retry window on lock-related errors

_ensureInit() is awaited by every op-log read/write, and the hydrator
auto-reloads on IndexedDB open errors. Applying the ~31s retry window
to every error class could create a reload -> wait -> reload loop that
feels like a hang. Classify the error on first failure and fall back
to a short retry budget (IDB_OPEN_RETRIES_NON_LOCK=2, ~3s window) for
errors that don't look lock-related. InvalidStateError and messages
containing "backing store" still get the full window used for stale
LevelDB locks on Linux desktop session restart. See #7191.

The spec is hardened to assert concrete constant floors rather than
recomputing the backoff formula (which only proved the formula matched
itself). Also adds unit tests for the classification helper.

* fix(persistence): address review feedback on IDB retry split

- Correct stale "auto-reload" rationale in op-log-errors.const,
  operation-log.const, operation-log-store.service, and archive-store.service:
  the hydrator shows a blocking alert dialog on IndexedDBOpenError, it does
  not auto-reload. The fail-fast argument now reflects the real reason —
  every op-log read/write awaits _ensureInit(), so a 31s wait on a non-lock
  error blocks the subsystem for 31s before the alert dialog surfaces.
- isLockRelatedIdbOpenError now checks `err instanceof DOMException || err
  instanceof Error` before reading .name/.message, mirroring the pattern in
  the sibling isConnectionClosingError. In some Electron / older runtimes
  DOMException does not satisfy instanceof Error.
- Added behavioral tests for _openDbWithRetry that spy on a new
  _openDbOnce testing seam: generic errors take exactly
  1 + IDB_OPEN_RETRIES_NON_LOCK attempts, InvalidStateError takes up to
  1 + IDB_OPEN_RETRIES, and a lock-error followed by success resolves.
- Bumped IDB_OPEN_RETRIES_NON_LOCK from 2 to 3 to match master's pre-PR
  retry count (1s + 2s + 4s = ~7s ceiling). Framing this as "keep master's
  existing retry count for non-lock errors, add long retry only for lock
  errors" is a lower-risk scope. Adjusted the const spec's upper-bound
  assertion accordingly.
- Replaced the "retries 1-5" hardcoded schedule comment in
  operation-log-store.service and archive-store.service with a formula-based
  comment so the two retry budgets can't drift out of sync with reality.
- Added two DOMException-shaped test cases to
  operation-log.const.spec.ts covering the new predicate branch.

* docs(persistence): clean up rot-prone worked examples in retry docstrings
2026-04-19 19:20:23 +02:00
..
app fix(persistence): increase IndexedDB retry window for session-restart locks (#7220) 2026-04-19 19:20:23 +02:00
assets Update Croatian translation (#7148) 2026-04-18 23:17:22 +02:00
environments 18.2.3 2026-04-18 23:24:19 +02:00
static
styles feat: change very small container to 356px 2026-04-01 20:23:45 +02:00
test-helpers
typings refactor: improve typing 2025-09-16 18:04:40 +02:00
_common.scss
favicon.ico
hammer-config.class.ts
index.html fix: show black logo on loading screen for light system theme 2026-03-20 21:36:30 +01:00
karma.conf.js build: fix windows build 2025-12-06 13:41:04 +01:00
main.ts fix(sync): scope interval timer to file-based providers and drop unneeded migration 2026-04-14 22:09:02 +02:00
manifest.json
polyfills.ts perf: reduce initial bundle size via lazy-loading 2026-03-10 15:58:22 +01:00
styles.scss fix(styles): use package imports for fontsource instead of relative paths 2026-03-18 13:14:10 +01:00
test.ts test: fix 2025-12-05 17:10:37 +01:00
tsconfig.app.json fix(build): exclude test helpers from production build 2026-02-25 16:46:51 +01:00
tsconfig.spec.json fix(shared-schema): fix module resolution for bundler compatibility 2026-01-11 13:20:16 +01:00
tsconfig.worker.json