Skip to content

Commit 71b6c65

Browse files
Add docs from gofiber/fiber@24752bc
1 parent af6858f commit 71b6c65

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/core/extra/faq.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,24 @@ For details on how to:
198198
* Convert `fiber.Ctx` to `http.Request`
199199

200200
See the dedicated documentation: [Adaptor Documentation](../middleware/adaptor.md).
201+
202+
## Troubleshooting common errors
203+
204+
Crashes that surface in unrelated packages, with stack traces that never mention Fiber, usually trace back to a context value kept past the handler. The cases below name the symptom so a search for the panic text lands here.
205+
206+
### Panic `id (N) <= evictCount (M)` (hpack / HTTP/2 / gRPC) {#panic-id-evictcount-hpack-grpc}
207+
208+
This is not a bug in Fiber, gRPC, or `golang.org/x/net/http2`. It means a Fiber zero-copy context value (a header from `c.Get`, or `c.Query`, `c.Params`, `c.Cookies`, `c.Body`) was kept past the handler. Fiber reuses the request buffer on the next request, so the retained bytes change underneath whatever stored them. See [Zero Allocation](../intro.md#zero-allocation) for the underlying behavior.
209+
210+
A common trigger is forwarding a header into a long-lived gRPC / HTTP/2 client's `metadata`. The value is held in the connection's HPACK dynamic table and later mutates, crashing the process inside the HPACK encoder, in a stack trace that never mentions Fiber:
211+
212+
```text
213+
panic: id (N) <= evictCount (M)
214+
golang.org/x/net/http2/hpack.(*headerFieldTable).idToIndex
215+
...
216+
google.golang.org/grpc/internal/transport.(*loopyWriter).writeHeader
217+
```
218+
219+
The crash is decoupled from your handler in both time and call stack, so ordinary tests and even the `-race` detector usually miss it.
220+
221+
The fix is to detach the value before you keep it: copy it with `utils.CopyString` (or `strings.Clone`), or enable [`Immutable`](../api/fiber.md#immutable). A full reproduction is in [gofiber/fiber#4464](https://github.com/gofiber/fiber/issues/4464).

0 commit comments

Comments
 (0)