Skip to content

Close should guarantee no more goroutines#330

@kylecarbs

Description

@kylecarbs

If Close is called after the HTTP server has been closed, a goroutine currently leaks.

package main import ( "context""net/http""net/http/httptest""go.uber.org/goleak""nhooyr.io/websocket" ) funcmain(){done:=make(chanstruct{}) srv:=httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r*http.Request){conn, err:=websocket.Accept(rw, r, nil) iferr!=nil{panic(err) } close(done) conn.Close(websocket.StatusNormalClosure, "") })) _, _, err:=websocket.Dial(context.Background(), srv.URL, nil) iferr!=nil{panic(err) } <-donesrv.Close() err=goleak.Find() iferr!=nil{panic(err) } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions