Fix:Improve error handling when a request fails due to the persistent connection being expired #761
Enhanced the do_api_query function with a retry mechanism (up to 3 attempts) for transient connection errors, configurable retry delays, and keep-alive headers. It resets the HTTP session on failures, differentiates between network errors and API errors, and maintains backward compatibility while improving reliability with optimized timeouts (90s for long-polling, 15s default).
- Implement retry mechanism (up to 3 attempts) for transient connection errors
- Add configurable retry delay and connection keep-alive headers
- Reset HTTP session on connection failures to ensure clean reconnect
- Differentiate between retryable network errors and API response errors
- Set appropriate timeouts (90s for long-polling, 15s default otherwise)
- Maintain backward compatibility while improving error resilience
Fixes: #761
How did you test this PR?
Self-review checklist
- [x] Self-reviewed the changes for clarity and maintainability (variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
- [x] Explains differences from previous plans (e.g., issue description).
- [x] Highlights technical choices and bugs encountered.
- [x] Calls out remaining decisions and concerns.
- [x] Automated tests verify logic where appropriate.
Individual commits are ready for review (see commit discipline).
- [x] Each commit is a coherent idea.
- [ ] Commit message(s) explain reasoning and motivation for changes.
Completed manual review and testing of the following:
- [ ] Visual appearance of the changes.
- [x] Responsiveness and internationalization.
- [ ] Strings and tooltips.
- [x] End-to-end functionality of buttons, interactions and flows.
- [x] Corner cases, error conditions, and easily imagined bugs.
Hello @avijitdas126, it seems like you have referenced #761 in your pull request description, but you have not referenced them in your commit message description(s). Referencing an issue in a commit message automatically closes the corresponding issue when the commit is merged, which makes the issue tracker easier to manage.
Please run git commit --amend in your command line client to amend your commit message description with Fixes #761..
An example of a correctly-formatted commit:
commit fabd5e450374c8dde65ec35f02140383940fe146
Author: zulipbot
Date: Sat Mar 18 13:42:40 2017 -0700
pull requests: Check PR commits reference when issue is referenced.
Fixes #51.
To learn how to write a great commit message, please refer to our guide.
Hello @avijitdas126, it seems like you have referenced #761 in your pull request description, but you have not referenced them in your commit message description(s). Referencing an issue in a commit message automatically closes the corresponding issue when the commit is merged, which makes the issue tracker easier to manage.
Please run git commit --amend in your command line client to amend your commit message description with Fixes #761..
An example of a correctly-formatted commit:
commit fabd5e450374c8dde65ec35f02140383940fe146
Author: zulipbot
Date: Sat Mar 18 13:42:40 2017 -0700
pull requests: Check PR commits reference when issue is referenced.
Fixes #51.
To learn how to write a great commit message, please refer to our guide.
@timabbott could you please review this PR?