Skip to content

Commit 3ff4b80

Browse files
fix(cpp): implement strict idempotency-aware retry policy and safe realtime state
1 parent c7e781b commit 3ff4b80

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

examples/cpp/include/appwrite/client.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ class Client {
386386
std::lock_guard<std::mutex> lock(cfg_mutex_);
387387
cfg_ = std::make_shared<const Config>(std::move(next));
388388
}
389-
// Only retry on network failure (status_code == 0).
390-
// 5xx errors are not retried — retrying non-idempotent requests
391-
// (POST, PATCH) would cause duplicate side effects.
389+
// Retry: idempotent methods (GET/PUT/DELETE/HEAD/OPTIONS) retry on network
390+
// failure, 429, and 5xx. POST/PATCH retry only on status_code==0 (request
391+
// never reached the server) to avoid duplicate side effects.
392392
static cpr::Response send(const Config& c, std::string_view m, std::string_view p, const auto& h, const auto& pms, bool no_redir = false) {
393393
int attempt = 0;
394394
while (true) {

templates/cpp/include/client.hpp.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ private:
389389
std::lock_guard<std::mutex> lock(cfg_mutex_);
390390
cfg_ = std::make_shared<const Config>(std::move(next));
391391
}
392-
// Only retry on network failure (status_code == 0).
393-
// 5xx errors are not retried — retrying non-idempotent requests
394-
// (POST, PATCH) would cause duplicate side effects.
392+
// Retry: idempotent methods (GET/PUT/DELETE/HEAD/OPTIONS) retry on network
393+
// failure, 429, and 5xx. POST/PATCH retry only on status_code==0 (request
394+
// never reached the server) to avoid duplicate side effects.
395395
static cpr::Response send(const Config& c, std::string_view m, std::string_view p, const auto& h, const auto& pms, bool no_redir = false) {
396396
int attempt = 0;
397397
while (true) {

0 commit comments

Comments
 (0)