From 929af941f83772a9f1a643c30690d7e8af9b70b3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 25 Jan 2026 08:02:27 -1000 Subject: [PATCH] [socket] Fix ESP8266 watchdog timeout when running high-frequency loops --- esphome/components/socket/lwip_raw_tcp_impl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/esphome/components/socket/lwip_raw_tcp_impl.cpp b/esphome/components/socket/lwip_raw_tcp_impl.cpp index 429f59ceca..9676487dea 100644 --- a/esphome/components/socket/lwip_raw_tcp_impl.cpp +++ b/esphome/components/socket/lwip_raw_tcp_impl.cpp @@ -29,6 +29,14 @@ void socket_delay(uint32_t ms) { // Use esp_delay with a callback that checks if socket data arrived. // This allows the delay to exit early when socket_wake() is called by // lwip recv_fn/accept_fn callbacks, reducing socket latency. + // + // When ms is 0, we must explicitly yield() because esp_delay(0, callback) + // exits immediately without yielding, which can cause watchdog timeouts + // when the main loop runs in high-frequency mode (e.g., during light effects). + if (ms == 0) { + yield(); + return; + } s_socket_woke = false; esp_delay(ms, []() { return !s_socket_woke; }); }