mswjs / interceptors

Low-level network interception library.
https://npm.im/@mswjs/interceptors
MIT License
563 stars 127 forks source link

caught (in promise) TypeError: Illegal invocation #405

Closed acheong08 closed 1 year ago

acheong08 commented 1 year ago
import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest';

const interceptor = new XMLHttpRequestInterceptor()

// Enable the interception of requests.
interceptor.apply()

// Listen to any "http.ClientRequest" being dispatched,
// and log its method and full URL.
interceptor.on('request', ({ request, requestId }) => {
  console.log(request.method, request.url)
})
plugin:sample-plugin:3177 Uncaught TypeError: Illegal invocation
    at next (plugin:sample-plugin:3177:28)
    at Proxy.setProperty (plugin:sample-plugin:3256:20)
    at handler.set (plugin:sample-plugin:3188:26)
    at window.ajax (enhance.js:1:11991)
    at e.logout (app.js:1:264780)
    at app.js:1:2424502
    at HTMLButtonElement.<anonymous> (app.js:1:1324908)

Caught here:

if (typeof (ownDescriptors == null ? void 0 : ownDescriptors.set) !== "undefined") {
        ownDescriptors.set.apply(target, [nextValue]);
        return
}
nextValue.toString()
'function(){var t=p.status,e=p.response;t>=200&&t<400?r&&r(e,p):o&&o(e,p)}'
target.toString()
'[object XMLHttpRequest]'
acheong08 commented 1 year ago

Note: This is inside electron

acheong08 commented 1 year ago

Solved. Seems to be a duplicate of #378