fix RequestCtx is canceled (#1879) (#1890)

Create done channel in fakeServer during the initialization of newRequestCtx to prevent the done channel from being nil
This commit is contained in:
Kashiwa
2024-10-28 03:15:57 +08:00
committed by GitHub
parent 40bdc4abc7
commit 803c25e54c
2 changed files with 11 additions and 0 deletions
+1
View File
@@ -2789,6 +2789,7 @@ func (ctx *RequestCtx) Value(key any) any {
}
var fakeServer = &Server{
done: make(chan struct{}),
// Initialize concurrencyCh for TimeoutHandler
concurrencyCh: make(chan struct{}, DefaultConcurrency),
}
+10
View File
@@ -4414,3 +4414,13 @@ func TestRequestBodyStreamReadIssue1816(t *testing.T) {
t.Fatal(err)
}
}
func TestRequestCtxInitShouldNotBeCanceledIssue1879(t *testing.T) {
var r Request
var requestCtx RequestCtx
requestCtx.Init(&r, nil, nil)
err := requestCtx.Err()
if err != nil {
t.Fatal(err)
}
}