question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cancelled network requests fail to resolve with cy.wait

See original GitHub issue

Current behavior

If a network request is aliased and the network request is cancelled by the browser, cy.wait will timeout waiting for the network request.

Desired behavior

cy.wait should complete with a failed network request and should convey that the request was cancelled.

Test code to reproduce

// Intercept an outbound request with `cy.intercept` and set it to an alias
cy.intercept("route-to-request", req => {
     req.id = "cancelled-request-id"
     req.reply()
}

// Redirect to a new page before the request resolves
cy.visit('http://localhost:3000/path-to-new-url')

// Wait for the cancelled request to resolve
cy.wait("@cancelled-request-id")

Cypress Version

9.1.1

Other

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
flotwigcommented, Dec 15, 2022

@mjhenkes this is fixed by #24709, right?

1reaction
jeremydornecommented, Dec 13, 2021

Poking around in the debugger, once cancelled intercepted requests get a response, they are marked with the state ResponseReceived but will never reach the Complete state.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Network Requests - Cypress Documentation
Stubbing a response's headers; Delaying a response; Waiting for a response to happen. Within Cypress, you have the ability to choose whether to...
Read more >
javascript - Cypress intercepted api request canceled (with ...
With new release of cypress 7.0.0, the API gives back a response and is no longer hitting the Err_empth_Response But still the cy.wait()...
Read more >
Cypress cy.intercept Problems - Gleb Bahmutov
This is the browser trying to be robust and retrying a failed network request. The browser sees a network error coming back from...
Read more >
Listen for Cancellation Requests That Have Wait Handles
In this article​​ If a method is blocked while it is waiting for an event to be signaled, it cannot check the value...
Read more >
A Practical Guide to Intercepting Network Requests in Cypress
wait () command to resolve, and only then start to look for our board item elements. Now that our .wait() is in place,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found