-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Description:-
-The Service Worker attempts to update cached responses in the background using fetch(event.request) inside event.waitUntil(). When the user is offline or the network request fails, this fetch promise rejects without a .catch() handler.
-This results in an Uncaught (in promise) TypeError: Failed to fetch error in the Service Worker context. Although the cached response or offline fallback is still served, the unhandled rejection introduces runtime errors and reduces reliability.
-Proper promise handling is required to ensure safe offline operation and error-free background cache updates.
Expected Behavior:-
-Background cache update requests should fail gracefully when offline.
-No unhandled promise rejections should occur in the Service Worker.
-Cached responses or offline fallback content should continue to be served normally.
-Network failures should be safely ignored where appropriate.
How to Reproduce:-
-Open Music Blocks in a browser.
-Ensure the Service Worker is active.
-Load a page/resource so it is cached.
-Turn off internet connectivity.
-Refresh or navigate to trigger a cached response.
-Observe the browser console.
-You may see:
->Uncaught (in promise) TypeError: Failed to fetch
-Console log Errors:
->Uncaught (in promise) TypeError: Failed to fetch
->Occurs when offline and background fetch fails.
Environment:
-Operating System: Windows / macOS / Linux
-Browser: Chrome / Firefox / Edge / Safari
-Version of Software/Project: Latest (master branch)
Impact:
-Medium
-Generates unnecessary runtime errors in offline scenarios
-Reduces Service Worker reliability
-May affect debugging and error monitoring
Suggested Fix:
-Add a safe .catch() handler to the background fetch inside event.waitUntil():
=>fetch(event.request)
.then(...)
.catch(() => {
// ignore offline failures
});
Checklist
- I have read and followed the project's code of conduct.
- I have searched for similar issues before creating this one.
- I have provided all the necessary information to understand and reproduce the issue.
- I am willing to contribute to the resolution of this issue.
Thank you for contributing to our project! We appreciate your help in improving it.
π See contributing instructions.
ππΎππΌ Questions: Community Matrix Server.