Skip to content

bug: service worker maintenance gaps — VERSION never bumped, trimCache under-trims, PRECACHE omits /map #169

Description

@shauryagangrade

Problem

Audit of public/sw.js:

  1. Dead cleanup code: VERSION = "studymap-v1" (line 4) is never bumped by any build step, so the activate-time old-cache deletion (lines 22-32) can never fire and stale caches persist forever across deploys.
  2. trimCache lags: it deletes exactly one entry per call while over limit (lines 34-38), so the tile cache can sit far above TILE_LIMIT.
  3. PRECACHE gaps (line 8): omits /map — arguably the app's core route for offline use — plus built CSS/fonts.
  4. Silent registration failure: src/components/pwa-register.tsx:10 swallows errors with .catch(() => {}), so broken SW updates are invisible.

Suggested fix

  • Derive/inject a version at build time (e.g. replace a placeholder in a prebuild step) so cleanup actually runs
  • Loop trimCache until under limit
  • Add /map to PRECACHE; log registration failures in dev

Acceptance criteria

  • Deployed updates invalidate old caches
  • Tile cache respects its limit

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchoreMaintenance / cleanup

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions