Fix client monitoring rate limit errors - #5189
Merged
wemeetagain merged 1 commit intoFeb 21, 2023
Merged
Conversation
Ensure next interval only starts after previous request has finished else we might send next request too early and run into rate limit errors.
nflaig
force-pushed
the
fix-monitoring-rate-limit-errors
branch
from
February 21, 2023 11:18
a809022 to
c2fba44
Compare
nflaig
commented
Feb 21, 2023
| } | ||
|
|
||
| private nextMonitoringInterval(): void { | ||
| if (this.status === Status.Stopped) return; |
Member
Author
There was a problem hiding this comment.
This check just prevents an edge case which can happen due to a race condition where this.send() has not yet finished but service was stopped, it would invoke this.nextMonitoringInterval() again and keep the interval running even though service is already stopped.
This is probably never relevant if the BN or VC run as standalone services because the whole process will be stopped either way but if it is embedded in another software this might matter.
Member
Author
There was a problem hiding this comment.
Just noting here that this change is also quite important if BN or VC are standalone services as setting another timeout would prevent the process from exiting
wemeetagain
approved these changes
Feb 21, 2023
Member
|
馃帀 This PR is included in v1.6.0 馃帀 |
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.
Motivation
Follow up change for #5037 which fixes beaconcha.in rate limit errors.
Description
The current implementation might send the next request too early if the previous one took a bit longer due to the nature of how
setIntervalworks, it does not wait for async functions to finish.This change ensure we are only starting the next interval after the previous request has finished.
Reverts changes done in this commit as setting interval to 62 seconds did not actually fix the issue just made it less likely to happen.
We can safely set the interval to 60 seconds now as we will only start the next interval after we the get previous response which means the sent interval might vary a bit (usually just a few milliseconds) depending on the response times of the remote service.