grafana/k6 · error
route is already handled
Error message
route is already handled
What it means
Single-use guard in Route.startHandling: each intercepted request route can be completed exactly once, and a boolean "handled" flag is flipped on the first fulfill/abort/continue call. This error is returned when a second completion is attempted on the same Route — e.g., script logic calls both route.fulfill() and route.continue(), or an abort/continue race after a timeout handler already fulfilled.
Solutions
- Call exactly one of route.fulfill(), route.abort(), or route.continue() per intercepted request
- Return early from the handler after the first completion call
- Clear any timers (setTimeout fallbacks) that may complete the route after the main handler already did
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/http.go:909 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/f52d0df400b5739a.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/http.go:908
return err
}
return r.networkManager.ContinueRequest(r.request.interceptionID, opts, r.request.HeadersArray())
}
// Fulfill fulfills the request with the given options for the response.
func (r *Route) Fulfill(opts FulfillOptions) error {
err := r.startHandling()
if err != nil {
return err
}
return r.networkManager.FulfillRequest(r.request, opts)
}
func (r *Route) startHandling() error {
if r.handled {
return fmt.Errorf("route is already handled")
}
r.handled = true
return nil
}
View on GitHub (pinned to 8d06114777)