-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Responses with delay hang forever with "got" #426
Comments
This happens also with the async/await: const { BatchInterceptor } = require('@mswjs/interceptors')
const { default: nodeInterceptors } = require('@mswjs/interceptors/presets/node')
const got = require('got')
const axios = require('axios')
const interceptor = new BatchInterceptor({
name: 'my-interceptor',
interceptors: nodeInterceptors,
})
interceptor.apply();
interceptor.on('request', async function ({ request, requestId }) {
await new Promise(resolve => setTimeout(resolve, 2000))
console.log(request.url);
request.respondWith(new Response('', { status: 200 }))
})
(await got('http://example.test')).statusCode // stuck
(await axios.get('http://example.test')).status // work |
@mikicho, can you share what the logs tell us by running the test like this? DEBUG=* <YOUR_TEST_COMMAND> There will be more detailed steps of what Interceptors are doing. Expecting to see a line about "no mocks found" and that it completes the original request. This may be a corner case if either of the libraries so let's dig deeper. We have basic automated tests with |
I'm not sure what it says or if I did something wrong. but It prints no debug stuff, just the URL (from the interceptor listener). |
@kettanaito Seems like
|
The logs look okay. May be an improperly constructed test. Will look at it a bit later. |
From what I see, this promise was never resolved: Update1: Update2: Update3: |
That error is expected. Interceptors actually tries to perform the request and captures any errors that occur. That way if there's no mock response for that request, it will then replay those errors. |
@kettanaito Update: Another thing I noticed. I inject the request ( Look at |
I'm tackling an issue that can be related to this race condition you've mentioned. I'd like to see if the Got issue still persists once I merge that one. |
@kettanaito amazing work! Thank you very much for the quick response! 🙏 |
Released: v0.25.3 🎉This has been released in v0.25.3! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
I'm not sure if it's a
got
error ormswjs/interceptors
one.This is working with
axios
and nativefetch
The text was updated successfully, but these errors were encountered: