-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: Browser will freeze when sync request is intercepted #32925
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
base: develop
Are you sure you want to change the base?
Conversation
|
|
Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the |
The routeHandler is executed but the request that goes to the server won't be modified req.headers["foo"] = "bar" The server will not get this since it's not resolved, but anything you console.log in the routeHandler will print in DevTools console |
|
Ok, I see the |
|
The second part of the fix (7b4f2e7) fixes a freezing issue when there's a sync request in cy.origin block The downside is cross-origin cookies most likely won't work in this case In cases where you must use |
|
Thanks for cross origin explanation. I'll have to look into it further. |
This issue happens when a synchronous request is intercepted and the
routeHandlerargument to cy.intercept is givenThe second part of this PR (prevent cross origin cookies from breaking sync requests)
@jennifer-shehane will want to discuss before adding unit tests, etc
Additional details
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?Note
Avoids browser hangs when cy.intercept handles synchronous XMLHttpRequest by tagging sync requests and bypassing awaits/cookie automation in proxy and runner.
packages/net-stubbing/):intercepted-request.ts, immediately emit intercept events for synchronous requests by checkingreq.isSyncRequestto skip awaiting route handlers.packages/proxy/):request-middleware.ts: extract and removex-cypress-is-sync-requestheader; setreq.isSyncRequest.response-middleware.ts: when simulated cookies are added, skip cookie automation flow for synchronous requests to avoid hangs.types.ts: addisSyncRequest: booleantoCypressIncomingRequest.packages/runner/injection/):main.jsandpatches/xmlHttpRequest.ts: patchXMLHttpRequest.open/sendto mark synchronous requests by settingx-cypress-is-sync-requestand bypass async credential signaling for sync requests.cli/CHANGELOG.md: add bugfix note for freeze on intercepted synchronous requests.Written by Cursor Bugbot for commit 12a25e4. This will update automatically on new commits. Configure here.