Skip to content

Commit fc964b9

Browse files
authored
fix: remove prerequests from automation client when bidi continue request errors (#31328)
* fix: make sure to remove prerequests when bidi interceptor is removed and requests are still in flight from the previous spec/tab [run ci] * fix changelog
1 parent a566242 commit fc964b9

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

cli/CHANGELOG.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
_Released 3/25/2025 (PENDING)_
55

6+
**Bugfixes:**
7+
8+
- Applies a fix from [#30730](https://github.com/cypress-io/cypress/pull/30730) and [#30099](https://github.com/cypress-io/cypress/pull/30099) related to Node.js turning on ESM flags by default in Node.js version `20.19.0`. Fixed in [#31308](https://github.com/cypress-io/cypress/pull/31308).
9+
- Fixed an issue where Firefox BiDi was not correctly removing prerequests on expected network request failures. Fixes [#31325](https://github.com/cypress-io/cypress/issues/31325).
10+
611
**Dependency Updates:**
712

813
- Upgraded `@cypress/request` from `3.0.7` to `3.0.8`. Addressed in [#31311](https://github.com/cypress-io/cypress/pull/31311).
@@ -12,11 +17,6 @@ _Released 3/25/2025 (PENDING)_
1217
- Upgraded `semver` from `7.5.3` to `7.7.1`. Addressed in [#31341](https://github.com/cypress-io/cypress/pull/31341).
1318
- Upgraded `systeminformation` from `5.21.7` to `5.22.8`. Addressed in [#31281](https://github.com/cypress-io/cypress/pull/31281).
1419

15-
**Bugfixes:**
16-
17-
- Applies a fix from [#30730](https://github.com/cypress-io/cypress/pull/30730) and [#30099](https://github.com/cypress-io/cypress/pull/30099) related to Node.js turning on ESM flags by default in Node.js version `20.19.0`. Fixed in [#31308](https://github.com/cypress-io/cypress/pull/31308).
18-
19-
2020
## 14.2.0
2121

2222
_Released 3/12/2025_

packages/server/lib/browsers/bidi_automation.ts

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ export class BidiAutomation {
216216
cookies: params.request.cookies,
217217
})
218218
} catch (err: unknown) {
219+
debugVerbose(`error continuing request: %o`, err)
220+
debugVerbose(`removing prerequest for request ID: ${params.request.request}`)
221+
// if the continueRequest fails for any reason, we need to remove the prerequest from the automation client
222+
this.automation.onRemoveBrowserPreRequest?.(params.request.request)
219223
// happens if you kill the Cypress app in the middle of request interception. This error can be ignored
220224
if (!(err as Error)?.message.includes('no such request')) {
221225
throw err

packages/server/test/unit/browsers/bidi_automation_spec.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,18 @@ describe('lib/browsers/bidi_automation', () => {
368368
})
369369
})
370370

371-
it('swallows "no such request" messages if thrown via killing the Cypress app', () => {
371+
it('swallows "no such request" messages if thrown via killing the Cypress app and removes the related prerequest', async () => {
372372
BidiAutomation.create(mockWebdriverClient, mockAutomationClient)
373373

374374
mockWebdriverClient.networkContinueRequest = sinon.stub().throws('no such request')
375375

376376
expect(() => {
377377
mockWebdriverClient.emit('network.beforeRequestSent', mockRequest)
378378
}).not.to.throw()
379+
380+
await flushPromises()
381+
382+
expect(mockAutomationClient.onRemoveBrowserPreRequest).to.have.been.calledWith('request1')
379383
})
380384
})
381385

0 commit comments

Comments
 (0)