From 970c7afa3eec37ee7319387a4fd82546849a0383 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Wed, 22 Apr 2026 18:57:40 -0700 Subject: [PATCH] fix(githubsync): add HTTP timeout and JSON filter to prevent sync failure on slow connections and large repos --- plugins/githubsync/GitHubSyncPlugin.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/githubsync/GitHubSyncPlugin.cpp b/plugins/githubsync/GitHubSyncPlugin.cpp index 27371cb..8f7df42 100644 --- a/plugins/githubsync/GitHubSyncPlugin.cpp +++ b/plugins/githubsync/GitHubSyncPlugin.cpp @@ -71,6 +71,7 @@ bool downloadFile(const std::string& rawUrl, const std::string& pat, HTTPClient http; http.begin(client, rawUrl.c_str()); + http.setTimeout(15000); http.addHeader("User-Agent", "CrossPoint-GitHubSync/1.0"); if (!pat.empty()) { std::string auth = "token " + pat; @@ -137,6 +138,8 @@ bool fetchTree(RepoInfo& info, const std::string& pat, http.addHeader("Authorization", auth.c_str()); } + http.setTimeout(15000); + int code = http.GET(); if (code != 200) { LOG_ERR("GHS", "Tree fetch HTTP %d for branch %s", code, branches[i]); @@ -144,10 +147,19 @@ bool fetchTree(RepoInfo& info, const std::string& pat, continue; } + JsonDocument filter; + filter["sha"] = true; + JsonArray filterTree = filter["tree"].to(); + JsonObject filterItem = filterTree.add(); + filterItem["type"] = true; + filterItem["path"] = true; + filterItem["sha"] = true; + WiFiClient* stream = http.getStreamPtr(); JsonDocument doc; - DeserializationError err = deserializeJson(doc, *stream); + DeserializationError err = deserializeJson(doc, *stream, + DeserializationOption::Filter(filter)); http.end(); if (err != DeserializationError::Ok) {