Skip to content

πŸ› [Bug]: Client execFunc goroutine has no panic recovery β€” crash on fasthttp panicΒ #4356

@pageton

Description

@pageton

Bug Description

The Fiber HTTP client's execFunc() goroutine has no recover(). If fasthttp.Do(), any hook, or CopyTo() panics, the entire process crashes. The channels are also never drained, causing the caller to hang or leak.

How to Reproduce

Steps to reproduce the behavior:

  1. Use the Fiber client with a custom hook that panics
  2. Call req.Send()
  3. The panic propagates through the goroutine and crashes the server

Affected Code

client/core.go:80-136:

go func() {
    defer releaseErrChan(errChan)
    defer releaseResponseChan(respChan)
    // ... HTTP execution logic ...
    respChan <- resp  // never reached if panic occurs
}()

Expected Behavior

Add panic recovery that sends the error through the channel:

go func() {
    defer releaseErrChan(errChan)
    defer releaseResponseChan(respChan)
    defer func() {
        if r := recover(); r != nil {
            errChan <- fmt.Errorf("client panic: %v", r)
        }
    }()
    // ... existing logic ...
}()

Related

Fiber Version

v3 (latest main branch)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions