In my opinion, the root cause of issue #1879 is that the done channel in ctx.s is nil. We can simply create done channel in fakeServer during the initialization of RequestCtx.
Original
requestCtx.Init()
→ ctx.Init2
→ ctx.s = fakeServer (the ctx.s.done is nil)
requestCtx.Err()
→ ctx.Done() (generate the new buffered channel and send struct{}{} since the ctx.s.done is nil)
→ error is returned
Fix
requestCtx.Init()
→ ctx.Init2
→ ctx.s = fakeServer (the ctx.s.done is initialized)
requestCtx.Err()
→ ctx.Done() (return ctx.s.done since it is non nil)
→ error is nil
In my opinion, the root cause of issue #1879 is that the
done
channel inctx.s
is nil. We can simply createdone
channel infakeServe
r during the initialization of RequestCtx.Original
Fix