Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crawler): separate timeout per query #999

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@
for i := 0; i < c.parallelism; i++ {
go func() {
defer wg.Done()
ctx, cancel := context.WithTimeout(ctx, c.queryTimeout)
defer cancel()
for p := range jobs {
res := c.queryPeer(ctx, p)
qctx, cancel := context.WithTimeout(ctx, c.queryTimeout)
res := c.queryPeer(qctx, p)
cancel() // do not defer, cleanup after each job

Check warning on line 153 in crawler/crawler.go

View check run for this annotation

Codecov / codecov/patch

crawler/crawler.go#L151-L153

Added lines #L151 - L153 were not covered by tests
results <- res
}
}()
Expand Down