Skip to content
Merged
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
8 changes: 8 additions & 0 deletions packages/webdriverio/src/utils/interception/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export default class DevtoolsInterception extends Interception {

static handleRequestInterception (client: CDPSession, mocks: Set<Interception>): (event: Event) => Promise<void | ClientResponse> {
return async (event) => {
// Race condition: if mock was already restored on client side
// But browser managed to send "Fetch.requestPaused" event before it received "Fetch.disable"
// Client-side "mocks" is already cleaned up, but browser is waiting for request instructions
// In this case we have to send "Fetch.continueRequest" to browser and do nothing more
if (!mocks) {
return client.send('Fetch.continueRequest', { requestId: event.requestId }).catch(/* istanbul ignore next */logFetchError)
}

// responseHeaders and responseStatusCode are only present in Response stage
// https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#event-requestPaused
const isRequest = !event.responseHeaders && !event.responseErrorReason
Expand Down
Loading