fix(metrics): honor context cancellation when collecting metrics - #211
Open
skyc1e wants to merge 1 commit into
Open
fix(metrics): honor context cancellation when collecting metrics#211skyc1e wants to merge 1 commit into
skyc1e wants to merge 1 commit into
Conversation
Collaborator
🟡 Heimdall Review Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A metrics endpoint that stalls before sending headers or while streaming its response leaves
Collect(ctx, ...)blocked even after the caller cancels the context. All four collectors currently usehttp.Get, which does not receive that context.Create the HTTP request with the caller's context in the builder, reth, geth, and base-reth-node collectors. Cancellation now interrupts both the request and response-body reads, while preserving the existing client, parsing, body cleanup, and wrapped errors.
Add local HTTP-server tests for each collector covering successful collection and cancellation before headers and during a partial response body. Canceled scrapes must return
context.Canceledand must not record a block.Testing
Collectdid not return after cancellation.go test ./... -timeout=5m: all packages pass except the existingTestResolveConfigFilePathfailure on Windows (backslash paths versus slash expectations). Reproduced that failure in a separate, unchanged checkout of52f715f.go vet ./...: passes.gofmt;git diff --checkpasses.