-
Notifications
You must be signed in to change notification settings - Fork 83
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
app/eth2wrap: fix lazy client if http times out #2035
Conversation
return &lazy{ | ||
provider: provider, | ||
} | ||
} | ||
|
||
// lazy is a client that is created on demand. | ||
type lazy struct { | ||
provider func() (Client, error) | ||
providerMu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one caller will try to resolve the client if it doesn't exit. But use a separate lock so that other calls do not block when trying to read the client
l.mu.Lock() | ||
defer l.mu.Unlock() | ||
// Try until we get the provider lock or the context is cancelled. | ||
for !l.providerMu.TryLock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only way to wait for a lock while respecting context cancel
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2035 +/- ##
==========================================
+ Coverage 53.40% 53.43% +0.03%
==========================================
Files 174 174
Lines 22481 22493 +12
==========================================
+ Hits 12005 12020 +15
+ Misses 8968 8967 -1
+ Partials 1508 1506 -2
... and 5 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@corverroos we need to upgrade to go1.20.3 for govulncheck. Not a blocker though. |
Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving. category: bug ticket: none
Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving. category: bug ticket: none
Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving.
category: bug
ticket: none