You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(examples/{react,solid}/offline): regenerate the msw worker and render after it starts - #11974
Regenerate public/mockServiceWorker.js in the react offline example for msw 2.15.0. The committed worker was from an older msw version, so every mocked request failed and the movie list never loaded.
Add the missing public/mockServiceWorker.js to the solid offline example. Without it, the worker failed to register and no request was mocked.
Render both apps after worker.start() resolves, following msw's deferred mounting, so the first queries and the mutations resumed after a reload are not sent before the worker is ready.
I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact
This change affects published code, and I have generated a changeset.
This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
Bug Fixes
React and Solid offline examples now wait for the service worker to start before rendering, helping ensure requests are handled consistently from the beginning.
Improved offline request handling, including passthrough behavior and support for streaming responses.
Updates
Updated the service worker used by the Solid offline example to match the current worker behavior.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
The React and Solid offline examples update service-worker request handling, client messaging, passthrough handling, and response lifecycle data. Both apps now render only after worker.start() resolves. The Solid app validates its root before starting the worker.
Changes
Offline examples
Layer / File(s)
Summary
Worker lifecycle and client resolution examples/react/offline/public/mockServiceWorker.js, examples/solid/offline/public/mockServiceWorker.js
The workers handle installation, activation, integrity checks, and client tracking. They resolve active clients for intercepted requests.
Request interception and lifecycle messages examples/react/offline/public/mockServiceWorker.js, examples/solid/offline/public/mockServiceWorker.js
The workers serialize request data and send request and response lifecycle data to active clients. They omit response bodies for text/event-stream responses.
Response routing and client messaging examples/react/offline/public/mockServiceWorker.js, examples/solid/offline/public/mockServiceWorker.js
The workers route mock responses and passthrough requests, remove the passthrough value from the Accept header, and transfer message payloads where applicable.
Render after worker startup examples/react/offline/src/index.tsx, examples/solid/offline/src/index.tsx
Both apps render after worker.start() resolves. The Solid app validates its root element before starting the worker.
sequenceDiagram
participant Browser
participant ServiceWorker
participant ActiveClient
participant Network
Browser->>ServiceWorker: Send intercepted request
ServiceWorker->>ActiveClient: Send serialized request
ActiveClient-->>ServiceWorker: Return mock response or PASSTHROUGH
alt Mock response
ServiceWorker-->>Browser: Return mock response
else PASSTHROUGH
ServiceWorker->>Network: Fetch request without passthrough Accept value
Network-->>ServiceWorker: Return network response
ServiceWorker-->>Browser: Return network response
end
Loading
Merge Risk:⚪ Minimal · up to 17d8d
This updates the offline examples so mocked requests work, using a regenerated service worker and rendering only after the worker has started. No actionable merge risk was found.
Pre-merge checks | 5
✅ Passed checks (5 passed)
Check name
Status
Explanation
Title check
The title clearly summarizes the main changes: regenerating the MSW workers and delaying rendering until worker startup completes.
Description check
The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, reports testing, confirms policy compliance, and identifies the change as dev-only.
Docstring Coverage
Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
public/mockServiceWorker.jsin the react offline example for msw 2.15.0. The committed worker was from an older msw version, so every mocked request failed and the movie list never loaded.public/mockServiceWorker.jsto the solid offline example. Without it, the worker failed to register and no request was mocked.worker.start()resolves, following msw's deferred mounting, so the first queries and the mutations resumed after a reload are not sent before the worker is ready.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit