Closed KayleighYum closed 3 months ago
Hi, @KayleighYum. Thanks for bringing this up.
This doesn't seem to be related to MSW though. If you are intercepting that request, no DNS lookup will be made, in the first place. If you are performing a passthrough request, it falls under how Node.js behaves, and this isn't the right place to document such behaviors.
Have you experienced this issue when you have a matching request handle for a *.local
request?
Hi @kettanaito, thanks for replying!
I should've made it more clear, yes this issue was occurring when I had a matching request handle for *.local
. I wasn't using passthrough, I returned a HttpResponse.json({...})
Got it. But the mocked response was still correctly returned, no? The tests timed out due to how long it takes for the URL
parser to parse the .local
domain, if I'm not mistaken.
That's correct, I understand your point that it's not a MSW issue, thanks for taking the time to reply!
Scope
Improves an existing behavior
Compatibility
Feature description
I recently had this issue: I was using a base url of http://example.local/ in an integration test and the test would take +- 8 seconds to resolve. After trying many different options, I changed the url to be http://example.localhost and the test resolved within the expected timeframe (+- 3 seconds).
It turns out that .local is a special host name in dns and node does a lookup for .local that doesn't resolve which then caused the tests to timeout. I proved this using the node:dns api process._getActiveRequests() This was quite time-consuming and frustrating to figure out, could this be added to the documentation as warning not to use .local urls?