Skip to content

Feature/fetch comments exponential retries #153

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

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

Conversation

brtmax
Copy link

@brtmax brtmax commented Dec 23, 2024

Timeout for fetching comments was set to 5 seconds, which on a slowish connection sometimes lead to a
timeout error (context deadline exceeded) when entering comment section mode.

I have only encountered this on stories with a large amount of comments. I believe the timeout occurs because the function attempts to fetch all comments associated with the story at once, which can be too much for slower connections or stories with a lot of comments.

This PR adds retry logic with exponential backoff and random jitter to the FetchComments function to handle timeouts more gracefully. (5s, 10s, 15s) It retries the request with increasing delays if the server is slow to respond. If all retries fail, an error gets logged. Of course this can be seen as a local fix, maybe something larger is needed in the future in order to achieve a more comprehensive solution to error handling of this kind. At least it seems to have fixed the timeouts for me, and I have not seen it posted elsewhere.

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

Successfully merging this pull request may close these issues.

1 participant