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

client/asset/eth: break immediately on shutdown when timing out #2191

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Feb 28, 2023

Resolves #2045

Turns out the timeouts there before shutdown were (wait for it)... DNS. The only actual issue there was that shutting down when eth.checkForNewBlocks was timing out would involve a random chance of receiving from the canceled context instead of the ticker.

This change checks for a shutdown that may have occurred while eth.checkForNewBlocks timed out. I've decided to keep the ticker because with health providers, it is desirable to keep a regular check interval in terms of wall time rather than relative to the previous check. Tickers don't backup indefinitely, but they will buffer a single tick, so a single tick may be delayed when there is a timeout.

func (eth *ETHWallet) checkForNewBlocks(reportErr func(error)) {
ctx, cancel := context.WithTimeout(eth.ctx, 2*time.Second)
func (eth *ETHWallet) checkForNewBlocks(ctx context.Context, reportErr func(error)) {
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same actual context, but I we're moving toward best practices.

@chappjc chappjc merged commit 3cb388a into decred:master Mar 1, 2023
@chappjc chappjc deleted the eth-shutdown-now branch March 1, 2023 14:15
@chappjc chappjc added this to the 0.6 milestone Mar 1, 2023
@chappjc chappjc added the ETH label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eth rpc: timeouts and failing connections need better handling
3 participants