Skip to content

Commit e422665

Browse files
committed
Fix 'cannot create context from nil parent' panic
An issue introduced with the v0.0.10 to support standard context.Context for net/http does not use an initialized context, causing the `context` package to panic with `cannot create context from nil parent`. This commit changes `nctx` so that it is initialized with the `context.Background()` value.
1 parent 7745ea0 commit e422665

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (s *Server) Upgrade(ctx *fasthttp.RequestCtx) {
197197
ctx.Response.Header.AddBytesK(wsHeaderProtocol, proto)
198198
}
199199

200-
var nctx context.Context
200+
nctx := context.Background()
201201
ctx.VisitUserValues(func(k []byte, v interface{}) {
202202
nctx = context.WithValue(nctx, string(k), v)
203203
})

0 commit comments

Comments
 (0)