Skip to content

Commit 2e7c804

Browse files
Merge pull request #36 from gemini-testing/INFRADUTY-29626.mocks_not_iterable
fix: race condition with cdp mocks
2 parents 808d431 + 5a027bf commit 2e7c804

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/webdriverio/src/utils/interception/devtools.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export default class DevtoolsInterception extends Interception {
3737

3838
static handleRequestInterception (client: CDPSession, mocks: Set<Interception>): (event: Event) => Promise<void | ClientResponse> {
3939
return async (event) => {
40+
// Race condition: if mock was already restored on client side
41+
// But browser managed to send "Fetch.requestPaused" event before it received "Fetch.disable"
42+
// Client-side "mocks" is already cleaned up, but browser is waiting for request instructions
43+
// In this case we have to send "Fetch.continueRequest" to browser and do nothing more
44+
if (!mocks) {
45+
return client.send('Fetch.continueRequest', { requestId: event.requestId }).catch(/* istanbul ignore next */logFetchError)
46+
}
47+
4048
// responseHeaders and responseStatusCode are only present in Response stage
4149
// https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#event-requestPaused
4250
const isRequest = !event.responseHeaders && !event.responseErrorReason

0 commit comments

Comments
 (0)