You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EAI_AGAIN Error Not Thrown on getaddrinfo Failure #3951
In undici versions @7.1.0, and @7.0.0 the EAI_AGAIN error is no longer thrown when the getaddrinfo syscall fails. Instead, the request returns an object with { opaque: null }, which is unexpected behavior.
Additionally, this issue might be related to fix: response error interceptor #3930.
Reproducible By
Attempt to make a request to a hostname that triggers a getaddrinfo failure.
Observe that instead of throwing an EAI_AGAIN error, the response contains { opaque: null }.
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.
In my use case, one microservice must request another one in the same docker network, but the one receiving the request is still not up.
Prior to version 7 we were receiving EAI_AGAIN if the microservice was not up with throwError, but now, with Undici 7, we just receive and empty response without any error even if there is nobody to reply.
The order of the interceptors matter, that's why you get one or the other depending on that.
I couldn't reproduce the initial error, as the response-error successfully throw on every network condition as expected.
For the combination of interceptors problems, I found the problem and the fix is on its way.
Activity
ruizmarc commentedon Dec 16, 2024
Hi,
We are also facing this problem and it's quite annoying as it is now harder to find out that one of services it is down it is not ready yet.
Is a fix coming soon? If not, is there any workaround?
Thanks in advance!
mcollina commentedon Dec 16, 2024
Thanks for reporting!
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.
ruizmarc commentedon Dec 16, 2024
Hi,
Here you have an example, you only need to do a simple request with the errors interceptor:
In my case I found the problem using docker, but it happens even without docker with a simple request. You can execute the example in this stackblitz: https://stackblitz.com/edit/node-fmjmkavv?file=index.js
In my use case, one microservice must request another one in the same docker network, but the one receiving the request is still not up.
Prior to version 7 we were receiving EAI_AGAIN if the microservice was not up with throwError, but now, with Undici 7, we just receive and empty response without any error even if there is nobody to reply.
paucabuti commentedon Dec 16, 2024
I found another issue related to interceptors while investigating the missing EAI_AGAIN error.
Using the dns interceptor in combination with the responseError interceptor causes inconsistent behavior depending on their order:
Here’s a reproducible example:
metcoder95 commentedon Dec 17, 2024
The order of the interceptors matter, that's why you get one or the other depending on that.
I couldn't reproduce the initial error, as the
response-errorsuccessfully throw on every network condition as expected.For the combination of interceptors problems, I found the problem and the fix is on its way.
ruizmarc commentedon Dec 17, 2024
Hi,
I don't know if by first error you are referring to the one I mentioned. Here you have a screenshot from the stackblitz showing the problem:
As you can see in the image, executing the code with the response error interceptor is not throwing any error
However, it works without the interceptor:
So the problem seems to be related with the response error interceptor that is not throwing the error in some cases.
Here the link to the stackblitz just in case it might help: https://stackblitz.com/edit/node-fmjmkavv?file=index.js
metcoder95 commentedon Dec 17, 2024
Yeah. was referring to this one. When attempting I was able to fully see the error being thrown (I tried with latest in
main)