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
Strange behaviour with throw in handlers #2616
Comments
Seems that the |
Domains are shit. You need to look into everything you are using in any extension, handler, pre, method, etc. that might have it's own client or domain context. Do you know where the error you do get comes from? It sounds like a handler is going through some async action that cross the domain boundary. The problem is that we can't fix anything involving domains... so we need to find workarounds for you to prevent the issue from happening in the first place. |
@hueniverse if "domains are shit", as you say, what would you recommend for handling request errors in a generic way? I'm struggling with similar problems. |
@qraynaud any chance you are using server methods or any caching provided by hapi? We had a bug in catbox where the throw from the first request would be passed to all other pending requests and mess up the domain stack. Also, is there any overlap between the two route (common code, ext.) that uses elastic search? We need to find a place where the two domains of each request cross over with something else. @mik01aj You just need to be very careful and have a good mapping of where your handler changes domains. It's hard. Most people don't hit the edge cases and when you do, like this, you need to dig deeper to see where you have overlapping context (such as two handlers both using the same HTTP connection and therefore crossing domains boundaries). |
@hueniverse : Yes, I was using catbox indeed. And no there is no overlap (other than catbox/yar) I can see between the 2 routes. I suppose I will update catbox asap then. Thanks for the tip. I'll keep in touch if this fixes the problem. |
This is not published yet. If you can manually try out the fix here: https://github.com/hapijs/catbox/pull/128/files before it is released, please report back if it solved your problem. |
I'm going to assume this is related to the catbox issue. Once 9.0 is out please check again and if it is still not resolved, open a new issue. Thanks! |
Ok thx. I'm sorry I have so little time for this right now. |
Hi,
I'm working on latest, so
v8.6.1
.I never noticed this before so maybe it's a recent bug, but when I throw in a handler, sometimes the error is sent to the wrong request.
Here is the route that fails:
This is only a test to showcase the problem, on a normal day, I would just reply the error.
I don't know if it can be related, but I have the following
onPreResponse
handler:I make multiple simultaneous requests using my browser. Most of the time it works but sometimes another request gets the error and I never get to have an answer on the throwing route.
Here is my network stack when it works:
And here is the result once every 5 times or so (this is random):
As you can see, a random call to my
i18n
endpoint failed and I got no answer for my call to_me
.The failing API call response looks like:
And here we can see that the error is the one emitted by
_me
that got no answer…Any ideas of what I might be doing wrong?
Another possibility might be my
i18n
endpoint that is using the officialelasticsearch
client that might or might not restore the domains properly. Could the other endpoint mess with my_me
route?The text was updated successfully, but these errors were encountered: