Skip to content

fix: make IndexedDB storage self-initializing to prevent startup failures#27

Merged
chiga0 merged 3 commits intomainfrom
copilot/fix-homepage-subscription-loading
Mar 5, 2026
Merged

fix: make IndexedDB storage self-initializing to prevent startup failures#27
chiga0 merged 3 commits intomainfrom
copilot/fix-homepage-subscription-loading

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

All storage operations (getAll, put, etc.) threw "Database not initialized" because init() was never called reliably before first use. Route loaders and page components each called storage.init().catch(...) independently, but useStore and feedService — the primary consumers — did not, and init() wasn't idempotent anyway.

Changes

  • src/lib/storage.ts: Every storage method now calls ensureInit() before accessing IndexedDB, making the class self-initializing
    • init() caches its promise in initPromise, so concurrent/repeated calls are safe
    • On failure, the cached promise is cleared to allow retry
  • Fixed broken JSDoc — unclosed /** block before bulkPut
  • Added 7 tests covering auto-init without explicit init(), concurrent init safety, and feed subscription integration without manual initialization

Before/After

// Before: every caller had to remember this, and many didn't
await storage.init().catch(() => {});
const feeds = await storage.getAll('feeds'); // throws if init() lost the race

// After: storage methods auto-initialize
const feeds = await storage.getAll('feeds'); // just works

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 4, 2026

Deploy Preview for rss-reader-pwa ready!

Name Link
🔨 Latest commit ac14d9a
🔍 Latest deploy log https://app.netlify.com/projects/rss-reader-pwa/deploys/69a86222db29ff00080f7ad4
😎 Deploy Preview https://deploy-preview-27--rss-reader-pwa.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI and others added 2 commits March 4, 2026 16:46
…d" errors

- Make storage.init() idempotent with cached init promise
- Add ensureInit() called by all storage methods before DB operations
- Fix dangling JSDoc comment in storage.ts
- Add unit tests for auto-initialization and concurrent init safety
- Add integration test for feed subscription without explicit init

Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com>
…reInit, improve test assertions

Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix block issue preventing homepage subscription loading fix: make IndexedDB storage self-initializing to prevent startup failures Mar 4, 2026
@chiga0 chiga0 marked this pull request as ready for review March 4, 2026 16:53
@chiga0 chiga0 merged commit eb9d369 into main Mar 5, 2026
6 checks passed
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.

2 participants