Skip to content

Commit 70b07df

Browse files
committed
PR review comments
1 parent 7082ede commit 70b07df

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

packages/driver/src/cypress/proxy-logging.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,13 @@ export default class ProxyLogging {
344344
return debug('unmatched responseReceived event %o', responseReceived)
345345
}
346346

347-
if (proxyRequest.xhr && proxyRequest.xhr.xhr.readyState !== 4) {
348-
const oldOnload = proxyRequest.xhr.xhr.onload
349-
const proxyLogging = this
350-
351-
proxyRequest.xhr.xhr.onload = function (...args) {
352-
if (oldOnload) {
353-
oldOnload.call(this, ...args)
354-
}
355-
356-
proxyLogging.updateProxyRequestWithResponse(proxyRequest, responseReceived)
357-
}
347+
if (proxyRequest.xhr && proxyRequest.xhr.xhr.readyState !== XMLHttpRequest.DONE) {
348+
proxyRequest.xhr.xhr.addEventListener('load', () => {
349+
this.updateProxyRequestWithResponse(proxyRequest, responseReceived)
350+
})
351+
} else {
352+
this.updateProxyRequestWithResponse(proxyRequest, responseReceived)
358353
}
359-
360-
this.updateProxyRequestWithResponse(proxyRequest, responseReceived)
361354
}
362355

363356
private updateRequestWithError (error: RequestError): void {

0 commit comments

Comments
 (0)