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: internal listeners infinite retry loop #284

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mikesposito
Copy link
Member

@mikesposito mikesposito commented Nov 13, 2024

Our block tracker implementation relies on the presence of listeners to establish whether the polling should be continued or stopped.

However, an internal listener is being added in the getLatestBlock method, which will count as the other external listeners and will prevent the instance from stopping fetching new blocks. This creates an infinite loop in case the network is unreachable, because of the retry mechanism.

This PR aims to fix this behavior by keeping track of internal listeners' references in order to exclude them from the listener's count

Fixes #163

@mikesposito mikesposito requested a review from a team as a code owner November 13, 2024 13:15
@mikesposito
Copy link
Member Author

It would be good to cover this with tests

@@ -54,6 +52,10 @@ export class PollingBlockTracker

private readonly _setSkipCacheFlag: boolean;

readonly #onLatestBlockInternalListeners: ((
Copy link
Member Author

Choose a reason for hiding this comment

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

Other class variables use private readonly _, but I suppose we'll want to change them sometime in the future.

I'm ok with aligning this with others for now if that looks better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endless failed request polling loop
2 participants