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

Consistently reject with a WorkboxError when a strategy fails #1657

Merged
merged 4 commits into from
Oct 4, 2018

Conversation

jeffposnick
Copy link
Contributor

@jeffposnick jeffposnick commented Sep 23, 2018

R: @philipwalton
CC: @devnook @sorendam

Fixes #1551, to be merged into the next branch.

Previously, some strategies would resolve with null instead of rejecting.

There are some updates to the docs that will end up accompanying this (once v4 goes live). For one thing, it makes it easier to provide fallback content via workbox.routing.setCatchHandler().

@jeffposnick jeffposnick added the Breaking Change Denotes a "major" semver change. label Sep 23, 2018
@jeffposnick jeffposnick added this to the v4 milestone Sep 23, 2018
Copy link
Member

@philipwalton philipwalton left a comment

Choose a reason for hiding this comment

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

LGTM with one optional suggestion.

@@ -123,7 +127,10 @@ class CacheOnly {
logger.groupEnd();
}

return response;
if (response) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: to me it'd make slightly more sense to invert this condition, i.e. throw when there's not a response and default to returning the response. As it is now, it looks like throwing is the default, unconditional behavior (but maybe that's just how I read it).

@@ -175,7 +179,10 @@ class NetworkFirst {
logger.groupEnd();
}

return response;
if (response) {
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above, here and presumably elsewhere.

@jeffposnick
Copy link
Contributor Author

Updated with review feedback.

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.51 KB 3.09 KB -12% 1.39 KB 🎉
packages/workbox-broadcast-cache-update/build/workbox-broadcast-cache-update.prod.js 1.12 KB 1.88 KB +68% 935 B ☠️
packages/workbox-build/build/index.js 4.02 KB 4.04 KB +0% 1.57 KB
packages/workbox-cache-expiration/build/workbox-cache-expiration.prod.js 3.88 KB 3.12 KB -20% 1.28 KB 🎉
packages/workbox-cli/build/app.js 6.76 KB 5.05 KB -25% 1.91 KB 🎉
packages/workbox-cli/build/bin.js 2.32 KB 1.57 KB -32% 799 B 🎉
packages/workbox-core/build/workbox-core.prod.js 7.47 KB 5.98 KB -20% 2.62 KB 🎉
packages/workbox-google-analytics/build/workbox-google-analytics.prod.js 2.12 KB 1.90 KB -11% 962 B 🎉
packages/workbox-precaching/build/workbox-precaching.prod.js 5.81 KB 5.01 KB -14% 2.12 KB 🎉
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.63 KB 1.49 KB -8% 744 B
packages/workbox-strategies/build/workbox-strategies.prod.js 5.09 KB 4.67 KB -8% 1.18 KB
packages/workbox-streams/build/workbox-streams.prod.js 1.57 KB 1.38 KB -12% 680 B 🎉
packages/workbox-webpack-plugin/build/generate-sw.js 8.04 KB 5.69 KB -29% 2.07 KB 🎉
packages/workbox-webpack-plugin/build/index.js 742 B 746 B +1% 468 B
packages/workbox-webpack-plugin/build/inject-manifest.js 10.30 KB 7.31 KB -29% 2.61 KB 🎉

New Files

No new files have been added.

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.51 KB 3.09 KB -12% 1.39 KB 🎉
packages/workbox-broadcast-cache-update/build/workbox-broadcast-cache-update.prod.js 1.12 KB 1.88 KB +68% 935 B ☠️
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/index.js 4.02 KB 4.04 KB +0% 1.57 KB
packages/workbox-cache-expiration/build/workbox-cache-expiration.prod.js 3.88 KB 3.12 KB -20% 1.28 KB 🎉
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 587 B 587 B 0% 347 B
packages/workbox-cli/build/app.js 6.76 KB 5.05 KB -25% 1.91 KB 🎉
packages/workbox-cli/build/bin.js 2.32 KB 1.57 KB -32% 799 B 🎉
packages/workbox-core/build/workbox-core.prod.js 7.47 KB 5.98 KB -20% 2.62 KB 🎉
packages/workbox-google-analytics/build/workbox-google-analytics.prod.js 2.12 KB 1.90 KB -11% 962 B 🎉
packages/workbox-navigation-preload/build/workbox-navigation-preload.prod.js 660 B 660 B 0% 319 B
packages/workbox-precaching/build/workbox-precaching.prod.js 5.81 KB 5.01 KB -14% 2.12 KB 🎉
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.63 KB 1.49 KB -8% 744 B
packages/workbox-routing/build/workbox-routing.prod.js 2.87 KB 2.87 KB 0% 1.31 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 5.09 KB 4.67 KB -8% 1.18 KB
packages/workbox-streams/build/workbox-streams.prod.js 1.57 KB 1.38 KB -12% 680 B 🎉
packages/workbox-sw/build/workbox-sw.js 1.50 KB 1.50 KB 0% 811 B
packages/workbox-webpack-plugin/build/generate-sw.js 8.04 KB 5.69 KB -29% 2.07 KB 🎉
packages/workbox-webpack-plugin/build/index.js 742 B 746 B +1% 468 B
packages/workbox-webpack-plugin/build/inject-manifest.js 10.30 KB 7.31 KB -29% 2.61 KB 🎉

Workbox Aggregate Size Plugin

9.44KB gzip'ed (63% of limit)
23.18KB uncompressed

@jeffposnick jeffposnick merged commit ca41e2e into next Oct 4, 2018
@jeffposnick jeffposnick deleted the throw-no-response branch October 4, 2018 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Denotes a "major" semver change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants