TestTimeout_HandlerReturnsEarlyOnCancel() — fiber Function Reference
Architecture documentation for the TestTimeout_HandlerReturnsEarlyOnCancel() function in timeout_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD c22022d7_4cc0_3cab_b87e_f04ea001fbce["TestTimeout_HandlerReturnsEarlyOnCancel()"] bab1b67e_4e42_cfe9_38ec_3f1f6a839718["timeout_test.go"] c22022d7_4cc0_3cab_b87e_f04ea001fbce -->|defined in| bab1b67e_4e42_cfe9_38ec_3f1f6a839718 style c22022d7_4cc0_3cab_b87e_f04ea001fbce fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/timeout/timeout_test.go lines 113–139
func TestTimeout_HandlerReturnsEarlyOnCancel(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Get("/early-return", New(func(c fiber.Ctx) error {
// Handler that would take 500ms but checks context
for i := 0; i < 50; i++ {
select {
case <-c.Context().Done():
return c.Context().Err()
case <-time.After(10 * time.Millisecond):
// Continue work
}
}
return c.SendString("completed")
}, Config{Timeout: 30 * time.Millisecond}))
req := httptest.NewRequest(fiber.MethodGet, "/early-return", http.NoBody)
start := time.Now()
resp, err := app.Test(req)
elapsed := time.Since(start)
require.NoError(t, err)
require.Equal(t, fiber.StatusRequestTimeout, resp.StatusCode)
// Should complete much faster than 500ms because handler checks context
require.Less(t, elapsed, 100*time.Millisecond)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestTimeout_HandlerReturnsEarlyOnCancel() do?
TestTimeout_HandlerReturnsEarlyOnCancel() is a function in the fiber codebase, defined in middleware/timeout/timeout_test.go.
Where is TestTimeout_HandlerReturnsEarlyOnCancel() defined?
TestTimeout_HandlerReturnsEarlyOnCancel() is defined in middleware/timeout/timeout_test.go at line 113.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free