Skip to content

Commit 361f689

Browse files
committed
Deal with Cloudflare bullshit
Closes #1 This is not a great solution for monitoring purposes though. Because this results in the service not dying, some other creative way to track downtime should likely be handled. I also need to find a way to coordinate this with stackchat.cpp, but I'm not sure how I want to go about that yet.
1 parent 5e556fb commit 361f689

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/stackapi/StackAPI.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ std::optional<nlohmann::json> StackAPI::checkErrors(cpr::Response& res, const AP
127127
throw std::runtime_error("Connection failed or internet dead (probably the latter): " + res.text + "; " + res.error.message);
128128
}
129129
} break;
130+
case 429:
131+
// Cloudflare bullshit
132+
if (opt.autoHandleBackoff.value_or(conf.autoHandleBackoff)) {
133+
spdlog::warn("Cloudflare says no. Sleeping for 5 minutes...");
134+
std::this_thread::sleep_for(std::chrono::minutes(5));
135+
} else {
136+
throw std::runtime_error("Cloudflare backoff");
137+
}
130138
case 500:
131139
case 503: {
132140
if (opt.autoHandleDowntime.value_or(conf.autoHandleDowntime)) {

0 commit comments

Comments
 (0)