-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Broken context propagation in HTTP request that involves hibernate-reactive-panache, resteasy-reactive and qute #27229
Comments
Isn't this the same issue we had with ActivateRequestContext? Having a quick look at InvocationInterceptor, I can see that it doesn't check if the method is reactive. Is this correct? By the way, it seems that only the first request fails, after that I don't have any erros. |
When calling |
I'm not sure but
You're right! And that's really an interesting clue... |
Similar because the interceptors involved here don't keep track of the fact that the method is reactive, so the context is destroyed/deactivated at the wrong time. |
Like I mentioned above the interceptors do not need to be involved at all... |
FTR this does not apply to |
It seems that the failure for the In other words, for these cases the request context is propagated correctly but the state of the I'm still not sure about the other issue with a template. We know that the UPDATE: |
So what's the conclusion on this one? |
No conclusion so far. We know the cause but I have no idea how to fix it. |
Is there something that shoyud be done in RR do you think? |
related to #27354 ? |
It could be, but I don't really think so |
Based on the discussion we had yesterday, I think that the changes that @mkouba and @cescoffier have in store will address this. Even if they don't, I am sure they will get us closer to fixing this. |
Qute use Completion Stage. Completion Stage creation needs to be decorated to be managed by context propagation. Another solution is to switch to Uni. |
Yes, #27443 if merged can solve part of the problem.
Note that only one of the broken use case involves qute. Two other broken cases fail for another reason. I will repeat myself: resteasy-reactive removes the current request on CDI request context deactivation which happens when a A workaround exists though - it should help if you initialize the injected |
I'm trying to quickly see if switching to Uni fixes the issue. |
What exactly do you have in mean? Qute won't internally switch to |
That's what I'm trying to do. If you do not do that, you need to track all the instantiation of CompletionStage and decorate them. |
@mkouba the other solution is to decorate like this every time you create a new CompletionStage:
(I let you decide which way you prefer because, switching to Uni will require a bit of work, but not missing any CompletionStage creation is also a source of bugs). |
Decoration of the completion stage will also require large modifications of the code base. |
Just to be clear, the issue here is not due to the removal of the request scope on suspension. Even with the PR changing, the request scope storage (which also avoids the removal) does not prevent this issue. |
I need to check and see what happens if the current context is not set to null |
If we move to the DuplicatedContext backed storage, then again there should be no reason to clear this (by calling |
And I also completely agree with @cescoffier that we need the Qute CS usages to be Context Propagation enabled |
This does not completely solve quarkusio#27229, but it is a step in the right direction.
Ensure that CDI request scope is active in TemplateResponseUniHandler
This does not completely solve quarkusio#27229, but it is a step in the right direction.
This does not completely solve quarkusio#27229, but it is a step in the right direction. (cherry picked from commit edfd611)
Awesome @mkouba ! |
Describe the bug
The CDI request context is not active when a template (that leverages a
@RequestScoped
bean) is rendered in aUni
chain:How to Reproduce?
hibernate-reactive-panache-quickstart
in the dev mode (can be reproduced in the prod mode as well)http://localhost:8080/test/template?id=1
You should see a
ContextNotActiveException
in the console.UPDATE: I've added two more simplified resource methods which produce a slightly different error:
It seems that the request context is active but the
CurrentVertxRequest
bean instance is not propagated.How to get this error:
http://localhost:8080/test/simple?id=1
- this one does not involve a qute templatehttp://localhost:8080/test/no-hibernate?id=1
- this one does not involvehibernate-reactive-panache
It might be as well a PEBKAC on my side. I would be more than happy if someone explains to me what's going on here ;-)
The text was updated successfully, but these errors were encountered: