Home / Function/ TestTimeout_ContextCleanup() — fiber Function Reference

TestTimeout_ContextCleanup() — fiber Function Reference

Architecture documentation for the TestTimeout_ContextCleanup() function in timeout_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  70866b94_3997_fca1_60c6_60e65ae9c468["TestTimeout_ContextCleanup()"]
  bab1b67e_4e42_cfe9_38ec_3f1f6a839718["timeout_test.go"]
  70866b94_3997_fca1_60c6_60e65ae9c468 -->|defined in| bab1b67e_4e42_cfe9_38ec_3f1f6a839718
  style 70866b94_3997_fca1_60c6_60e65ae9c468 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/timeout/timeout_test.go lines 392–419

func TestTimeout_ContextCleanup(t *testing.T) {
	t.Parallel()
	app := fiber.New()

	handlerDone := make(chan struct{})
	app.Get("/cleanup", New(func(c fiber.Ctx) error {
		defer close(handlerDone)
		<-c.Context().Done()
		// Small delay to simulate cleanup
		time.Sleep(50 * time.Millisecond)
		return nil
	}, Config{Timeout: 20 * time.Millisecond}))

	req := httptest.NewRequest(fiber.MethodGet, "/cleanup", http.NoBody)
	resp, err := app.Test(req)

	require.NoError(t, err)
	require.Equal(t, fiber.StatusRequestTimeout, resp.StatusCode)

	// Wait for handler to finish - cleanup goroutine should release context
	select {
	case <-handlerDone:
		// Give cleanup goroutine time to run
		time.Sleep(20 * time.Millisecond)
	case <-time.After(200 * time.Millisecond):
		t.Fatal("handler did not finish")
	}
}

Domain

Subdomains

Frequently Asked Questions

What does TestTimeout_ContextCleanup() do?
TestTimeout_ContextCleanup() is a function in the fiber codebase, defined in middleware/timeout/timeout_test.go.
Where is TestTimeout_ContextCleanup() defined?
TestTimeout_ContextCleanup() is defined in middleware/timeout/timeout_test.go at line 392.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free