Skip to content

updating proper error handling#13658

Draft
DmitryGron wants to merge 1 commit intolatestfrom
feature/worker-error
Draft

updating proper error handling#13658
DmitryGron wants to merge 1 commit intolatestfrom
feature/worker-error

Conversation

@DmitryGron
Copy link
Contributor

Resolves JIRA:

Summary

adding error handler for uncached promise

Code changes

  • List key code changes that have been made.

Testing

  1. List the steps required to test this PR.

Useful Links

Copilot AI review requested due to automatic review settings January 28, 2026 10:07
Copy link
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

This PR improves error handling in the service worker by properly returning a network error response instead of throwing an uncaught error when navigation requests fail for non-PWA users or when PWA users don't have a cached offline page.

Changes:

  • Replaced throw err with return Response.error() in the navigation fetch error handler to properly handle network failures

}
// fallback to browser default behavior
throw err;
return Response.error();
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The change from throwing an error to returning Response.error() is correct for service worker error handling. However, test coverage is missing for this specific error scenario. The existing test in src/sw.test.js only covers the case where navigation fails for PWA users who have an offline page cached. There should be a test case for when navigation fails for non-PWA users or PWA users without a cached offline page to verify that Response.error() is returned correctly.

Copilot uses AI. Check for mistakes.
@@ -170,8 +170,7 @@ const fetchEventHandler = async event => {
return cachedOffline;
}
}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The comment "fallback to browser default behavior" has been removed. While the new approach using Response.error() is correct, consider whether a comment explaining the error handling strategy would be helpful. For example: "Return network error response for failed navigation requests" to clarify that this intentionally returns an error response rather than attempting to show a generic offline page.

Suggested change
}
}
// Return network error response for failed navigation when no offline page is available

Copilot uses AI. Check for mistakes.
@elvinasv elvinasv marked this pull request as draft January 30, 2026 16:18
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