🐛 bug: Add nil checks to End() to prevent panic in streaming mode#4128
Draft
🐛 bug: Add nil checks to End() to prevent panic in streaming mode#4128
End() to prevent panic in streaming mode#4128Conversation
Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with context.End functionality
🐛 bug: Add nil check to Mar 4, 2026
End() to prevent panic in streaming mode
Member
|
@copilot check ctx before calling ctx.Conn(), that's where the panic could trigger. |
Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Contributor
Author
Copilot
AI
changed the title
🐛 bug: Add nil check to
🐛 bug: Add nil checks to Mar 4, 2026
End() to prevent panic in streaming modeEnd() to prevent panic in streaming mode
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4128 +/- ##
==========================================
- Coverage 91.07% 91.04% -0.04%
==========================================
Files 119 119
Lines 11377 11381 +4
==========================================
Hits 10362 10362
- Misses 645 647 +2
- Partials 370 372 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ctx.Conn()returnsnilwhen fasthttp is operating in streaming mode (async connection management), and the fasthttp context itself (r.c.fasthttp) can also benilafter being returned to the pool. Calling methods on a nil context orbufio.NewWriter(nil)on a nil connection causes a nil pointer panic.End()now returnsnilgracefully when either the context or connection is unavailable.Changes introduced
res.go: Added nil guard onctx(r.c.fasthttp) before callingctx.Conn(), and a nil guard onconnbefore writing/flushing. Updated godoc to document the streaming limitation.docs/api/ctx.md: Added:::warningadmonition clarifying thatEnd()is a no-op in streaming mode (HijackConn/SendStream) becausectx.Conn()may benil.docs/api/ctx.mdupdated with streaming caveat.End()no longer panics whenctxor connection is nil.Type of change
Checklist
/docs/directory for Fiber's documentation.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.