SharePoint Service Worker selectively blocks custom CDN assets while other assets from same origin load fine
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
None
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [ ] 💥 Microsoft Edge
- [x] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
No response
Describe the bug / error
The SharePoint Service Worker (spserviceworker.js) intermittently blocks specific JavaScript assets hosted on a custom CDN, while other assets from the exact same CDN origin and path load without issue. Disabling Service Workers entirely resolves the problem, which strongly suggests the issue lies in how the SP Service Worker intercepts and handles fetch requests.
Example:
We have two Web Parts whose resources are available in the same location on the CDN.
The first, profile_xxx_js, will be blocked, but the second, people_xxx.js, located in exactly the same place, will be allowed.
It is only after the Service Worker makes another attempt—without any user intervention—that the file will be loaded.
When Service Workers are disabled, the problem goes away.
When they are re-enabled, the problem reappears.
Steps to reproduce
- Load a SharePoint page that preloads multiple JS assets from a custom CDN (same origin, same path prefix, same version).
- Observe that some assets load correctly (HTTP 200 via ServiceWorker) while others fail with net::ERR_FAILED or CORS error.
- The failing asset eventually recovers and loads via the Service Worker after several retries — without any user action.
- Forcing a hard refresh (Ctrl+Shift+R) does not fix the issue.
- Disabling Service Workers in Chrome DevTools (Application > Service Workers > Bypass for network) makes all assets load correctly every time.
- Re-enabling Service Workers causes the issue to reappear.
Expected behavior
All assets from the same CDN origin should be handled consistently by the Service Worker — either all intercepted or all passed through, without arbitrary failures.
Hello @jbolliet-jint, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
Hello @jbolliet-jint,
Thank you for the detailed investigation and repro steps.
Based on the behavior you've described, this appears to be related to how the SharePoint Service Worker handles concurrent SPFx asset requests from a custom CDN — rather than an issue with the CDN itself. The key indicators are:
- Some assets fail with net::ERR_FAILED while others from the same CDN origin succeed
- The failing asset eventually loads after a Service Worker retry, without any user action
- Disabling Service Workers resolves the issue consistently; re-enabling causes it to reappear
- This pattern is consistent with a race condition in the Service Worker's fetch event handling when multiple dynamic imports fire concurrently.
We are escalating this to the engineering team to confirm whether this is expected behavior or an unintended edge case in the current Service Worker implementation.
In the meantime, as a temporary workaround during development: Chrome DevTools → Application → Service Workers → check "Bypass for network".
To help the engineering team investigate further, could you please share:
- A HAR file captured during reproduction (DevTools → Network → right-click → Save all as HAR)
- Your SPFx version (npm ls @microsoft/sp-core-library)
- Does the failure happen on every page load or intermittently?
- Does it happen with a single web part using Promise.all, or only when multiple web parts are on the same page simultaneously?
We'll follow up once we hear back from the engineering team.
Hello @Ashlesha-MSFT ,
Apologies for the delay in getting back to you.
Please find attached some example HAR files captured while reproducing the issue with the asset mzk-who-is-who_61978cc8d6de32f20708.js. The exports were generated today.
- errors-cors-solo-wp.har: only one webpart in the page
- errors-cors-multi-wp.har: multiple webparts in the page
One important observation is that the CORS errors visible in the browser's Network tab are not explicitly represented as such in the exported HAR file.
Live capture filtered on mzk-who-is-who_61978cc8d6de32f20708.js:
HAR export view filtered on mzk-who-is-who_61978cc8d6de32f20708.js:
I also verified that all relevant request and response headers were correctly included in the HAR export.
Regarding your questions:
-
SPFx version: 1.21.1
-
Does the issue occur on every page load? Yes.
-
Does the issue disappear after a hard refresh or after some time? Yes, the issue disappears after a hard refresh and may also disappear after several days.
-
Does it happen with a single web part using
Promise.all, or only when multiple web parts are present on the same page?I find this question particularly interesting because it is very specific and seems to suggest that a potential root cause may already be known.
The issue can be reproduced whether there is a single web part or multiple web parts on the page. However,
Promise.allis not used anywhere in our project codebase, although it may potentially be used by one of our dependencies.
Please let me know if any additional information or diagnostics would be helpful.
We're seeing the exact same behavior on a separate tenant, and I can add two data points that I think strengthen the case significantly.
Environment: SharePoint Online, modern pages, Chrome. The tenant uses third-party SPFx products (Mozzaik365 + a newsletter Application Customizer) whose CDN assets fail intermittently, identical to what's described here — CORS / Failed to fetch surfaced through spserviceworker.js, plus the Event handler of 'message' event must be added on the initial evaluation of worker script warning. Service worker build in use: https://res-1.public.onecdn.static.microsoft/files/odsp-web-prod_2026-06-05.009/spserviceworker.js.
Data point 1 — native page, zero third-party code or CDN: The failure is not limited to custom-CDN assets — it also hits SharePoint's own out-of-the-box page rendering.
- Create a brand-new modern page with the default OOTB page header (color header, no image, no web parts, no custom script).
- Reload repeatedly. The native header intermittently fails to render — sometimes the full header with title/author, sometimes nothing but the floating author avatar.
- Ctrl+F5 resolves it only inconsistently.
- Checking
Application > Service Workers > Bypass for networkmakes the header render correctly on every reload. Unchecking it brings the failure back immediately.
Since the repro is on a vanilla page with no custom CDN, the intermittently failing fetches include SharePoint's own CDN-hosted assets. This points to a core fetch-handling defect in the service worker rather than anything tenant-, vendor-, or CDN-specific.
Data point 2 — unexpected global resolution after enabling Bypass for network: After checking "Bypass for network" on a single local DevTools session, the issue appeared to resolve across all users on the tenant — not just the local browser. This is not consistent with the expected scope of "Bypass for network" (which should only affect the local DevTools session). We cannot explain this behavior, but we're reporting it as-is in case it provides a useful signal for diagnosing the server-side or SW cache invalidation mechanism involved.
Mechanism clarification: "Bypass for network" does not unregister or stop the service worker — it stays registered and "activated and running". It only routes the page's requests around the SW's fetch handler. Since bypassing the fetch interception alone deterministically resolves the failures, the defect is isolated to the SW's fetch interception/relay logic, not its registration or lifecycle.
Impact: production intranets degraded across multiple site collections, no deployable workaround available for end users.
Happy to provide HAR captures or full console logs if that helps triage. Screenshots of the native header in failed vs. rendered state attached below.