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

Add a check to wait for the resulting client ID #2210

Merged
merged 7 commits into from
Sep 26, 2019
Merged

Conversation

philipwalton
Copy link
Member

R: @jeffposnick

Fixes #2203, fixes #2204

To fix #2203, this PR adds a resultingClientExists() method that accepts a resultingClientId value and awaits the existence of the client. It can also resolve to undefined in one of two conditions:

  • The passed resultingClientId value is undefined (as will happen in a browser that doesn't support it).
  • The function tries for 2 seconds and still does not find a matching client.

Then, to fix #2204, in the BroadcastCacheUpdate class, I've added a timeout that waits for an additional 3.5 seconds (explanation here) in Safari or if the resultingClientExists() function doesn't find a matching client. (Note: I've added a TODO to remove the Safari check once this bug has been released.)

I've also updated the integrations to be more comprehensive. Previously there was only a test for resource requests, so I've added:

  • A test verifying a message gets sent on navigation requests and is actually received by the resulting page
  • A test verifying the message is sent to all window clients

@philipwalton philipwalton force-pushed the resulting-client branch 2 times, most recently from 1bf0e19 to 515b669 Compare September 2, 2019 18:27
@philipwalton
Copy link
Member Author

For some reason the workbox-window integration tests consistently fail for this PR, despite no changes being made to that package and other PRs with the same base branch running just fine.

I think let's merge a few of the other open workbox-window-related PRs and then rebase this on top of them. I suspect that might magically fix things.

const reg = await wb.register();
const updatefoundPromise = new Promise((resolve) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test from yesterday needed a bit more cleaning up, as there was a race condition in which the updatefound listener might not have been registered in time to catch the update. Registering the listener early and then waiting later on for the promise resolution should fix that.

@philipwalton philipwalton force-pushed the resulting-client branch 2 times, most recently from 8a2c728 to ba96115 Compare September 5, 2019 23:12
@philipwalton
Copy link
Member Author

Updated to skip the failing test in Safari. @jeffposnick can you PTAL.

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-broadcast-update/build/workbox-broadcast-update.prod.js 1.02 KB 1.27 KB +24% 700 B ☠️
packages/workbox-core/build/workbox-core.prod.js 6.42 KB 6.80 KB +6% 2.82 KB
packages/workbox-precaching/build/workbox-precaching.prod.js 4.95 KB 4.84 KB -2% 1.87 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.87 KB 3.87 KB 0% 1.60 KB
packages/workbox-broadcast-update/build/workbox-broadcast-update.prod.js 1.02 KB 1.27 KB +24% 700 B ☠️
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/generate-sw.js 1.99 KB 1.99 KB 0% 966 B
packages/workbox-build/build/get-manifest.js 1.60 KB 1.60 KB 0% 779 B
packages/workbox-build/build/index.js 613 B 613 B 0% 344 B
packages/workbox-build/build/inject-manifest.js 3.13 KB 3.13 KB 0% 1.36 KB
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 610 B 610 B 0% 356 B
packages/workbox-cli/build/app.js 4.16 KB 4.16 KB 0% 1.64 KB
packages/workbox-cli/build/bin.js 940 B 940 B 0% 502 B
packages/workbox-core/build/workbox-core.prod.js 6.42 KB 6.80 KB +6% 2.82 KB
packages/workbox-expiration/build/workbox-expiration.prod.js 2.95 KB 2.95 KB 0% 1.27 KB
packages/workbox-google-analytics/build/workbox-offline-ga.prod.js 1.97 KB 1.97 KB 0% 915 B
packages/workbox-navigation-preload/build/workbox-navigation-preload.prod.js 659 B 659 B 0% 322 B
packages/workbox-precaching/build/workbox-precaching.prod.js 4.95 KB 4.84 KB -2% 1.87 KB
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.58 KB 1.58 KB 0% 800 B
packages/workbox-routing/build/workbox-routing.prod.js 3.09 KB 3.09 KB 0% 1.35 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 4.10 KB 4.10 KB 0% 1.13 KB
packages/workbox-streams/build/workbox-streams.prod.js 1.44 KB 1.44 KB 0% 697 B
packages/workbox-sw/build/workbox-sw.js 1.34 KB 1.34 KB 0% 746 B
packages/workbox-webpack-plugin/build/generate-sw.js 4.22 KB 4.22 KB 0% 1.61 KB
packages/workbox-webpack-plugin/build/index.js 349 B 349 B 0% 255 B
packages/workbox-webpack-plugin/build/inject-manifest.js 5.10 KB 5.10 KB 0% 1.77 KB
packages/workbox-window/build/workbox-window.dev.umd.js 41.51 KB 41.51 KB 0% 9.20 KB
packages/workbox-window/build/workbox-window.prod.umd.js 4.52 KB 4.52 KB 0% 1.85 KB

Workbox Aggregate Size Plugin

3.51KB gzip'ed (23% of limit)
7.93KB uncompressed

@coveralls
Copy link

Coverage Status

Coverage remained the same at 79.293% when pulling e9169d2 on resulting-client into 7560ee1 on master.

@jeffposnick jeffposnick merged commit 5fc46f0 into master Sep 26, 2019
@jeffposnick jeffposnick deleted the resulting-client branch September 26, 2019 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants