Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ _Released 09/02/2025_
- Fixed an issue where the open Studio button would incorrectly show for component tests. Addressed in [#32315](https://github.com/cypress-io/cypress/pull/32315).
- Fixed an issue where the TypeScript compiler wasn't being resolved correctly when `@cypress/webpack-batteries-included-preprocessor` was used as a standalone package. Fixes [#32338](https://github.com/cypress-io/cypress/issues/32338).
- Fixed an issue where `tsx` was not being loaded correctly into the Cypress configuration process due to spaces being present in the path. Fixes [#32398](https://github.com/cypress-io/cypress/issues/32398).
* Fixed an issue where `cy.wait('@alias')` could time out when the underlying network request was canceled by navigation (e.g., `cy.visit`, `cy.reload`). Fixes [#19326](https://github.com/cypress-io/cypress/issues/19326).

**Misc:**

Expand Down
1 change: 0 additions & 1 deletion npm/cypress-schematic/src/schematics/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ function generateCTSpec ({ tree, appPath, component }: { tree: Tree, appPath: st
const componentFilename = component['name'].split('.')[0]
const componentName = componentMatch ? componentMatch[0] : componentFilename

// eslint-disable-next-line no-console
console.log(`Creating new component spec for: ${componentName}\n`)

return tree.create(`${appPath}/${componentFilename}.component.cy.ts`, ctSpecContent({ componentName, componentFilename }))
Expand Down
22 changes: 22 additions & 0 deletions packages/driver/cypress/e2e/commands/navigation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,28 @@ describe('src/cy/commands/navigation', () => {
})
})
})

it('should resolve wait for a request canceled by navigation', () => {
const alias = crypto.randomUUID()

cy.intercept(/jsonplaceholder.cypress.io/).as(alias)

cy.visit('https://example.cypress.io/commands/network-requests')
cy.get('.network-btn').click()

cy.visit('https://example.cypress.io/commands/network-requests')
cy.wait(`@${alias}`).then((interception) => {
const actual = JSON.parse(
JSON.stringify(interception, (_, value) => value),
)

cy.wrap(actual).should('deep.equal', {
...actual,
state: 'Errored',
error: { ...interception.error },
})
})
})
})

// TODO(webkit): fix+unskip for webkit release
Expand Down
31 changes: 31 additions & 0 deletions packages/driver/src/cy/commands/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ const pageLoading = (bool, Cypress, state) => {
Cypress.action('app:page:loading', bool)
}

const markRequestAsCancelled = (request: any) => {
if (
request &&
request.state === 'Received' &&
!request.response &&
!request.error
) {
request.state = 'Errored'
request.error = new Error('Request was cancelled due to navigation.')
}
}

const stabilityChanged = async (Cypress, state, config, stable) => {
debug('stabilityChanged:', stable)

Expand All @@ -188,6 +200,25 @@ const stabilityChanged = async (Cypress, state, config, stable) => {
return
}

// Mark inflight requests as canceled at navigation start.
try {
const routes = state('routes') ?? {}

_.forEach(routes, ({ requests }) => {
_.forEach(requests, markRequestAsCancelled)
})

const aliasedRequests = state('aliasedRequests') ?? []

aliasedRequests.forEach(({ request }) => {
markRequestAsCancelled(request)
})
} catch (_) {
// TODO: Should I use `$errUtils.logError` or another method from
// `$errUtils` here? Alternatively, should I do nothing, since canceled
// requests aren't necessarily a problem in Cypress?
}

// if we purposefully just caused the page to load
// (and thus instability) don't log this out
if (knownCommandCausedInstability) {
Expand Down
1 change: 1 addition & 0 deletions packages/electron/lib/print-node-version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// eslint-disable-next-line no-console
console.log(process.version.replace('v', ''))
process.exit(0)
Loading