-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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: fix performance issue for service workers that don't handle requests #28900
Conversation
Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently a "Comment" doesn't override "Request changes", so I'm "Approving" to avoid a dangling "Request changes" status.
This is only with regard to the changelog entry though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly typescript & DRY quibbles, otherwise lgtm!
packages/proxy/test/unit/http/util/service-worker-injector.spec.ts
Outdated
Show resolved
Hide resolved
packages/proxy/test/unit/http/util/service-worker-manager.spec.ts
Outdated
Show resolved
Hide resolved
packages/proxy/test/unit/http/util/service-worker-manager.spec.ts
Outdated
Show resolved
Hide resolved
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
We fixed an issue in 13.6.3 involving service workers to ensure that we could capture those requests properly for Test Replay and intercepts. Currently, when a service worker is registered, we incorrectly assumed that all requests would be handled by the service worker. Thus, if a request was not handled, the proxy would fail to correlate causing a timeout.
In order to resolve the issue, we are now overriding the fetch event and respondWith methods within the service worker to determine if
respondWith
was called.MaybeInjectServiceWorker
response middleware that injects code into the top of the service worker to overwrite theaddEventListener
,removeEventListener
,onfetch
, andrespondWith
functions.addEventListener
andonfetch
functions will now determine ifrespondWith
was called and call the CDP binding to inform theServiceWorkerManager
whether or not the service worker handled the request.removeEventListener
function is needed to appropriately remove the added listeners__cypressServiceWorkerClientEvent
that is used to communicate the events from the clientServiceWorkerManager
will now wait until it is notified by the client if the service worker is handling the request before communicating to the proxy to ignore the browser's pre-requestSteps to test
How has the user experience changed?
Unhandled service worker requests will no longer hit the 2 second correlation timeout.
PR Tasks
cypress-documentation
?type definitions
?