Skip to content

fix: take over foreign Service Worker scope when the served app changes - #87

Merged
drgould merged 1 commit into
mainfrom
fix-bookmarklet-conversat
Aug 26, 2026
Merged

fix: take over foreign Service Worker scope when the served app changes#87
drgould merged 1 commit into
mainfrom
fix-bookmarklet-conversat

Conversation

@drgould

@drgould drgould commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • mdp's routing Service Worker registers at scope /, shared by every repo that ever runs mdp run on a given proxy port over time
  • a leftover SW from a previous app on that port keeps intercepting fetches (and serving from its own Cache Storage) for whatever app is served here now, producing mismatched-build breakage
  • widget.js now detects when the served app (window.__mdpServedBy) has changed since the last visit (per-port fingerprint in localStorage) and takes over: unregisters any root-scoped foreign SW, clears Cache Storage, then does one guarded reload — a legitimate SW belonging to the current app is left alone

Test plan

  • go build ./...
  • go vet ./...
  • go test ./...

@drgould
drgould marked this pull request as ready for review August 26, 2026 21:34
@drgould
drgould merged commit 781dbc0 into main Aug 26, 2026
13 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.

1 participant