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

perf: support activated service worker that is not handling requests #29349

Merged
merged 41 commits into from Apr 23, 2024

Conversation

mschile
Copy link
Contributor

@mschile mschile commented Apr 17, 2024

Additional details

Currently, when a service worker is activated, we assume that the service worker is handling requests. However, a service worker doesn't start handling requests for the current scope unless clients.claim is called or a page within the scope is reloaded. In order to determine when a service worker is handling events, we are doing the following:

  • Added new clientsClaimed client event to inform the ServiceWorkerManager that the service worker is now handling requests.
  • Overrode clients.claim to send the clientsClaimed along with the clientUrls that were claimed.
  • Updated the ServiceWorkerManager to watch for document requests that come in that indicate the service worker is now handling requests.

Addressed a few other issues:

  • Stripped the hash from the url when receiving the service worker fetch event since the browser doesn't send hash causing the urls not to match which would lead to a timeout
  • Updated proxy to have access to the current browser so we can skip service worker injection for non-Chromium browsers
  • Since adding the browser pre-request to the queue is now async, it's possible for a cached response to be returned prior to the pre-request actually getting added. So, we now keep track of the pre-requests that were not able to be removed because they haven't been added and then skip adding them if they were removed.
  • Redirected requests don't go back through the service worker, so we are not storing off if a pre-request has a redirect response and if so, we do not wait for the fetch handler to be called.
  • Added a 250ms timeout to the service worker promise to ensure it doesn't hang indefinitely.

Steps to test

Load a page with a service worker but don't call clients.claim or reload the page. Verify additional requests sent by the page do not timeout.

How has the user experience changed?

Correlation timeouts are now longer experienced for service workers that are activated but not handling requests.

PR Tasks

@mschile mschile marked this pull request as draft April 17, 2024 16:26
Copy link

cypress bot commented Apr 17, 2024

5 failed and 4 flaky tests on run #55131 ↗︎

5 222 4 0 Flakiness 4

Details:

Merge branch 'develop' into mschile/service_worker_uncontrolled
Project: cypress Commit: d13e2e48a3
Status: Failed Duration: 14:10 💡
Started: Apr 23, 2024 5:13 PM Ended: Apr 23, 2024 5:27 PM
Failed  cypress\e2e\project-setup.cy.ts • 4 failed tests • launchpad-e2e

View Output

Test Artifacts
... > skips the setup page when choosing e2e tests to run Test Replay Screenshots
... > shows the configuration setup page when selecting e2e tests Test Replay Screenshots
... > can skip setup CT testing for an E2E project Test Replay Screenshots
Launchpad: Setup Project > openLink > opens docs link in the default browser Test Replay Screenshots
Failed  cypress\e2e\migration.cy.ts • 1 failed test • launchpad-e2e

View Output

Test Artifacts
global mode > migrates 2 projects in global mode Test Replay Screenshots
Flakiness  cypress\e2e\project-setup.cy.ts • 2 flaky tests • launchpad-e2e

View Output

Test Artifacts
... > can reconfigure config after CT has been set up Test Replay Screenshots
Launchpad: Setup Project > switch testing types > takes the user to first step of e2e setup when switching from app Test Replay Screenshots
Flakiness  cypress\e2e\scaffold-component-testing.cy.ts • 1 flaky test • launchpad-e2e

View Output

Test Artifacts
scaffolding component testing > react-vite-ts-unconfigured > scaffolds component testing for React and Vite Test Replay Screenshots
Flakiness  cypress\e2e\config-warning.cy.ts • 1 flaky test • launchpad-e2e

View Output

Test Artifacts
component testing dependency warnings > warns against outdated @vue/cli dependency Test Replay Screenshots

Review all test suite changes for PR #29349 ↗︎

@mschile mschile marked this pull request as ready for review April 18, 2024 01:57
@AtofStryker AtofStryker self-requested a review April 18, 2024 16:06
mschile and others added 2 commits April 19, 2024 09:49
Co-authored-by: Bill Glesias <bglesias@gmail.com>
@mschile mschile merged commit 867a973 into develop Apr 23, 2024
105 of 114 checks passed
@mschile mschile deleted the mschile/service_worker_uncontrolled branch April 23, 2024 17:52
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 23, 2024

Released in 13.8.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.8.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update after 13.6.3 runs in execution timeouts on CI/CD timeouts with upgrade to >=13.6.3
4 participants