sentry-symfony icon indicating copy to clipboard operation
sentry-symfony copied to clipboard

RequestFetcher doesn't return request

Open jkatruska opened this issue 1 year ago • 3 comments

How do you use Sentry?

Self-hosted / on-premises

SDK version

4.8.0

Steps to reproduce

Make any request with body and you won't see body or method in sentry.

The problem is in RequestFetcher which relies on getting request from RequestStack. The problem here is that the RequestIntegration which uses RequestFetcher to get request runs on kernel.terminate. By this time, the RequestStack is empty because the handle method of the HttpKernel pops that request from the stack and terminate is called after handle.

Expected result

Data from request will be logged in sentry

Actual result

No data from request are logged

jkatruska avatar Mar 10 '24 22:03 jkatruska

I started looking into this, we might need to cache the request somewhere early in the live cycle. We do the same in our Laravel SDK, so I think this should work in Symfony as well.

cleptric avatar Jul 02 '24 16:07 cleptric

Why caching? Wouldn't be enough to trigger that earlier, i.e. on kernel.request? Or even better, on-demand? We may need to investigate side-effects...

Jean85 avatar Jul 02 '24 16:07 Jean85

Because we need the data when an error happens (the easy part) and on transaction finish, which happens on kernel.terminate. Hence we store the request early, and have it laying around for the duration of the entire request.

cleptric avatar Jul 02 '24 16:07 cleptric

Hey, just wondering how it was working before, cause I have a feeling I have the same issue, which for some reason appears only in prod environment and only on some of the endpoints.

Did it appear on 5.0 release?

rsavuliak-macpaw avatar Aug 29 '24 11:08 rsavuliak-macpaw