Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove error logging caused by offline check #2777

Merged
merged 1 commit into from
Mar 12, 2021
Merged

Conversation

philipwalton
Copy link
Member

R: @jeffposnick @tropicadri

Fixes #2749

This PR removes confusing errors logged to the console in Chrome when doing the offline check. It does this by:

  • Changing the StrategyHandler#fetch() method's console level to LOG from ERROR when a network request fails. Since the strategy will also error if no response is returned (e.g. nothing is found in the cache), this message should be considered more informative than actionable.
  • Updating the StrategyHandler#fetch() and StrategyHandler#cacheMatch() methods to not call this.waitUntil() on the response. Calling waitUntil() in these situations is not necessary because SW implementations automatically wait on a fetch event's respondWith() promise. Furthermore, doing so in the StrategyHandler instance was causing response errors to be reported twice in some cases (leading do an unhandled promise rejection from the offline check).

Copy link
Contributor

@jeffposnick jeffposnick left a comment

Choose a reason for hiding this comment

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

Thanks, Phil! These code changes look fine to me.

Just to double-check before merging, with those changes in place, is it fine to keep the following as-is? That actually makes me less concerned about this being a "breaking" change, if so.

if (error) {
throw error;
}

@philipwalton
Copy link
Member Author

Yep, the error doesn't get that far with these changes.

@jeffposnick jeffposnick merged commit e5e08fb into v6 Mar 12, 2021
@jeffposnick jeffposnick deleted the offline-check-dx branch March 12, 2021 17:34
This was referenced Mar 15, 2021
This was referenced Mar 16, 2021
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.

Improve logging when Chrome's offline check fails
2 participants