From c4d9ed7b701ee2882ba49705bb5f80d4fd1b1fed Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 14 Dec 2025 17:06:53 +0000 Subject: [PATCH] [http_request] Fix infinite loop on read error in update component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The update component had the same infinite loop issue as the OTA component when network read errors occurred. If container->read() returned an error (negative value), it would be added to read_index and the loop would continue indefinitely since get_bytes_read() would never reach content_length. This fix breaks out of the read loop on any read error (read_bytes <= 0), preventing watchdog resets and infinite loops during manifest downloads. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .../components/http_request/update/http_request_update.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/http_request/update/http_request_update.cpp b/esphome/components/http_request/update/http_request_update.cpp index 26af754e69..22cad625d1 100644 --- a/esphome/components/http_request/update/http_request_update.cpp +++ b/esphome/components/http_request/update/http_request_update.cpp @@ -76,6 +76,11 @@ void HttpRequestUpdate::update_task(void *params) { yield(); + if (read_bytes <= 0) { + // Network error or connection closed - break to avoid infinite loop + break; + } + read_index += read_bytes; }