Skip to content

regression: after upgrade to 0.28 my websocket server no longer works 🐛 #836

@rjeczalik

Description

@rjeczalik

Summary

I have a service service mixed REST and Websocket requests over a single http.Server.

The sentry-go is setup the following way:

        srv.Server = &http.Server{
                Handler: sentryhttp.New(sentryhttp.Options{
                        Repanic:         true,
                        WaitForDelivery: false,
                        Timeout:         30 * time.Second,
                }).Handle(m),
                // ...

Websocket endpoint is using nhooyr/websocket to accept websocket connection, and it is pretty straightforward:

func (s *Server) createSubscription(w http.ResponseWriter, r *http.Request) {
        // ...

        conn, err := websocket.Accept(w, r, &websocket.AcceptOptions{
                CompressionMode: websocket.CompressionContextTakeover,
        })
        if err != nil {
                shared.Errorf(w, r, http.StatusInternalServerError, "failed to accept websocket connection: %w", err)
                return
        }

After upgrading from 0.27.0 to 0.28.0 the above endpoint no longer works, every request fails with:

failed to accept websocket connection: failed to accept WebSocket connection: http.ResponseWriter does not implement http.Hijacker

The reason is that go-sentry started overriding http.ResponseWriter which is now of the following type:

struct { httpsnoop.Unwrapper; http.ResponseWriter }{Unwrapper:(*httpsnoop.rw)( 0xc00039e6e0), ResponseWriter:(*httpsnoop.rw)( 0xc00039e6e0)}

Which clearly does not implement http.Hijacker interface.

Steps To Reproduce

  1. have a working websocket server
  2. upgrade sentry-go to 0.28.0
  3. ???
  4. no profit

Expected Behavior

  1. profit

Screenshots

n/a

Sentry.io Event

n/a

Environment

important

SDK

  • sentry-go version: 0.28.0
  • Go version: go1.22.3
  • Using Go Modules? yes

Sentry

  • Using hosted Sentry in sentry.io? yes
  • Anything particular to your environment that could be related to this issue? n/a

Additional context

n/a

Metadata

Metadata

Assignees

Labels

BugIssue type
No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions