sentry-go
sentry-go copied to clipboard
Implement hijacker interface for Negroni integration
Resolves https://github.com/getsentry/sentry-go/pull/837#issuecomment-2283914037
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 82.81%. Comparing base (
11d3c79) to head (e7df055). Report is 3 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #871 +/- ##
==========================================
- Coverage 82.83% 82.81% -0.03%
==========================================
Files 51 51
Lines 4597 4580 -17
==========================================
- Hits 3808 3793 -15
+ Misses 636 633 -3
- Partials 153 154 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
There are some breaking changes in here we need to call out on the changelog. Besides this, LGTM!
Are you referring to moving the WrapResponseWriter from sentryhttp to sentry?
That wasn't supposed to be exposed externally, so doubt anyone used it. To prevent a breaking change, we can keep it at sentryhttp as well (and just call the one at sentry internally)?
It’s ok, we just need to call it out 🙂
@cleptric Perhaps we should move the Hijacker interface to /internal?
Perhaps we should move the Hijacker interface to
/internal?
@ribice I'd say you should move it to internal package, but keep the one at sentryhttp to avoid breaking change, then add DEPRECATION notice (the one that's according to godoc format).
The one on sentryhttp should be a passthrough to internal package. Then after 2-3 minor version release, you can safely remove it.
Hi there,
I reported the originar issue with negroni + websockets: the response writter does not implement http.Hijacker interface. https://github.com/getsentry/sentry-go/pull/837#issuecomment-2283914037
Today we have upgraded from v0.27.0 to v0.29.0 and the error persists.
I've reviewed the code and I've found the issue: https://github.com/getsentry/sentry-go/blob/a6acd05f8d419d0445475b9018bd59fc0503b322/internal/httputils/wrap_writer.go#L35-L57
The w is of type *negroni.responseWriter in negroni v1, which is the one referenced by the sentry-go package.
This type implements http.Flusher, http.Hijacker, but not io.ReaderFrom.
So fl and hj are true, but rf is not. So in line 48 does not return the httpFancyWriter.
And it returns the basic flushWriter in line 53. (which does not support hijacker / websockets.
We have had to rollback our releases today as this was failing.
As mentioned before, negroni v1 uses a limited writer. This is solved in negroni v3, which is easy to migrate to, but it would be nice if go-sentry was upgraded to v3 too, as v1 was released in 2018. Having our project requiring both versions is a nightmare.
From my point of view, if go-sentry imports negroni v1, then the library should work with v1 (and this is not happening at the moment). If you expect people to be using v3 (which works with go-sentry v0.29.0) then you should import negroni v3 in your go.mod.
Please let me know your thoughts
Thank you!
@ribice can you take a look please?
Yes I can. Before I change the interface to support v1, I'm curious if we can update to v3? Is that an option?
Fine with me.
Thank you for looking into this guys :)
Upgraded negroni to latest version in #885. This worked just fine: https://gist.github.com/ribice/95934b3c209b9692efc4b50b91d5dd4a
@kydemy-fran Can you confirm that it works as expected with 0.29.1?
Hi there @ribice and @cleptric. I've just tested it and it seems to be working fine using the negroni v3 implementation. Thank you for your help!!