Skip to content

Conversation

@alexsch01
Copy link
Contributor

@alexsch01 alexsch01 commented Nov 10, 2025

This issue happens when a synchronous request is intercepted and the routeHandler argument to cy.intercept is given


The second part of this PR (prevent cross origin cookies from breaking sync requests)

  • prevents the browser from freezing when a sync request is made through the cross origin runner

@jennifer-shehane will want to discuss before adding unit tests, etc

Additional details

Steps to test

How has the user experience changed?

PR Tasks


Note

Marks and short-circuits synchronous XMLHttpRequests to bypass awaited intercept handlers and cookie automation, preventing browser freezes when a routeHandler is used.

  • Network stubbing (packages/net-stubbing):
    • InterceptedRequest.handleSubscriptions: skip awaiting handler responses when req.isSyncRequest to prevent blocking sync XHR.
  • Proxy (packages/proxy):
    • Request middleware: extract and strip x-cypress-is-sync-request header into req.isSyncRequest.
    • Response middleware: when simulating cross-origin cookies, skip automation wait if req.isSyncRequest.
  • Runner injection:
    • XMLHttpRequest.open/send patches: tag sync XHR with x-cypress-is-sync-request; bypass async credential signaling for sync requests.
  • Types:
    • Add isSyncRequest: boolean to CypressIncomingRequest.
  • Changelog:
    • Add bugfix entry for browser freeze when intercepting synchronous requests with a routeHandler.

Written by Cursor Bugbot for commit 6a21ef2. This will update automatically on new commits. Configure here.

@alexsch01 alexsch01 marked this pull request as draft November 10, 2025 15:06
@cypress-app-bot
Copy link
Collaborator

@alexsch01 alexsch01 marked this pull request as ready for review November 10, 2025 15:31
@mschile
Copy link
Contributor

mschile commented Nov 13, 2025

Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the routeHandler of the intercepted request would not be executed. Is my understanding correct?

@alexsch01
Copy link
Contributor Author

Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the routeHandler of the intercepted request would not be executed. Is my understanding correct?

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

@mschile
Copy link
Contributor

mschile commented Nov 14, 2025

Ok, I see the before:request event is still emitted but since this is a sync request, the event is received after the sync request has already been fully processed. I'm going to discuss this further with the team but my initial thought is that we should skip the adding the subscriptions entirely here.

@alexsch01
Copy link
Contributor Author

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 cy.origin due to navigating to a different subdomain, this allows the test to work as expected when there's a sync request

@mschile
Copy link
Contributor

mschile commented Nov 14, 2025

Thanks for cross origin explanation. I'll have to look into it further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser will freeze when sync request is intercepted

4 participants