Skip to content

fix(pwa): re-enable Workbox precaching (remove injectionPoint override)#611

Merged
7w1 merged 3 commits intoSableClient:devfrom
Just-Insane:fix/workbox-precaching
Apr 16, 2026
Merged

fix(pwa): re-enable Workbox precaching (remove injectionPoint override)#611
7w1 merged 3 commits intoSableClient:devfrom
Just-Insane:fix/workbox-precaching

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

Related to closed PR #548 (fix/media-error-handling), which was split into smaller focused PRs.

Description

injectionPoint: undefined was set in vite.config.ts to silence a Workbox AssertionError about multiple self.__WB_MANIFEST occurrences (an if guard in sw.ts plus the precacheAndRoute() call = two matches; Workbox requires exactly one). The unintended consequence: Workbox never injected the precache manifest, so no assets were precached — every cold start hit the network instead of serving from cache, and offline use was broken entirely.

Fix: remove the if guard in sw.ts (leaving exactly one self.__WB_MANIFEST reference) then remove injectionPoint: undefined from vite.config.ts to restore normal precaching behaviour.

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

The root cause diagnosis (two self.__WB_MANIFEST references causing Workbox to silently skip injection) was identified with AI assistance. I verified the fix by checking Workbox's injectionPoint behaviour and confirming precaching was restored.

@Just-Insane Just-Insane requested review from 7w1 and hazre as code owners March 31, 2026 18:43
@Just-Insane Just-Insane marked this pull request as draft March 31, 2026 20:13
@Just-Insane Just-Insane force-pushed the fix/workbox-precaching branch from e0162bd to 58176a6 Compare April 6, 2026 16:58
@Just-Insane Just-Insane marked this pull request as ready for review April 8, 2026 21:54
@Just-Insane Just-Insane deleted the fix/workbox-precaching branch April 12, 2026 19:33
@Just-Insane Just-Insane restored the fix/workbox-precaching branch April 12, 2026 19:41
@Just-Insane Just-Insane reopened this Apr 12, 2026
Copilot AI review requested due to automatic review settings April 15, 2026 15:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores Workbox InjectManifest precaching so the PWA service worker correctly receives and routes the __WB_MANIFEST, fixing cold-start/offline behavior regressions introduced by disabling manifest injection.

Changes:

  • Remove the extra self.__WB_MANIFEST reference in src/sw.ts by dropping the if guard, leaving a single injection point.
  • Remove the injectionPoint: undefined override in vite.config.ts so Workbox injects the precache manifest again.
  • Add a changeset documenting the precaching fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
vite.config.ts Re-enables Workbox manifest injection (and adjusts precache options).
src/sw.ts Ensures exactly one self.__WB_MANIFEST reference for Workbox InjectManifest.
.changeset/workbox-precaching.md Adds release note entry for the precaching fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vite.config.ts
Comment on lines +179 to +183
// element-call is a self-contained embedded app; exclude its large assets
// from the SW precache manifest (they are not part of the Sable shell).
globIgnores: ['public/element-call/**'],
// The app's own crypto WASM and main bundle exceed the 2 MiB default.
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MiB
@7w1 7w1 added this pull request to the merge queue Apr 16, 2026
Merged via the queue into SableClient:dev with commit b8ef241 Apr 16, 2026
15 of 16 checks passed
@Just-Insane Just-Insane deleted the fix/workbox-precaching branch April 17, 2026 19:06
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.

3 participants