Skip to content

Commit 803c25e

Browse files
authored
fix RequestCtx is canceled (#1879) (#1890)
Create done channel in fakeServer during the initialization of newRequestCtx to prevent the done channel from being nil
1 parent 40bdc4a commit 803c25e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,6 +2789,7 @@ func (ctx *RequestCtx) Value(key any) any {
27892789
}
27902790

27912791
var fakeServer = &Server{
2792+
done: make(chan struct{}),
27922793
// Initialize concurrencyCh for TimeoutHandler
27932794
concurrencyCh: make(chan struct{}, DefaultConcurrency),
27942795
}

server_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,3 +4414,13 @@ func TestRequestBodyStreamReadIssue1816(t *testing.T) {
44144414
t.Fatal(err)
44154415
}
44164416
}
4417+
4418+
func TestRequestCtxInitShouldNotBeCanceledIssue1879(t *testing.T) {
4419+
var r Request
4420+
var requestCtx RequestCtx
4421+
requestCtx.Init(&r, nil, nil)
4422+
err := requestCtx.Err()
4423+
if err != nil {
4424+
t.Fatal(err)
4425+
}
4426+
}

0 commit comments

Comments
 (0)