cypress: Cancelled network requests fail to resolve with cy.wait

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

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 9
  • Comments: 17 (5 by maintainers)

Most upvoted comments

This happens pretty consistently for us, it waits for all completed requests, but any cancelled ones timeout

Image

Image

Image

@mjhenkes this is fixed by #24709, right?

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.