From 848b1a303d631492a3e4eec00f0e04ee7a4671b0 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 16 Mar 2026 12:36:24 -1000 Subject: [PATCH] Restore HELPER_LOG in write_raw_ error paths --- esphome/components/api/api_frame_helper.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api_frame_helper.cpp b/esphome/components/api/api_frame_helper.cpp index 35c0fc8a08..88f308542b 100644 --- a/esphome/components/api/api_frame_helper.cpp +++ b/esphome/components/api/api_frame_helper.cpp @@ -114,9 +114,11 @@ APIError APIFrameHelper::write_raw_(const struct iovec *iov, int iovcnt, uint16_ // Drain any existing backlog first if (!this->overflow_buf_.empty()) [[unlikely]] { - if (this->overflow_buf_.try_drain(this->socket_.get()) == -1 && - this->check_socket_write_err_(errno) != APIError::WOULD_BLOCK) - return APIError::SOCKET_WRITE_FAILED; + if (this->overflow_buf_.try_drain(this->socket_.get()) == -1) { + HELPER_LOG("Socket write failed with errno %d", errno); + if (this->check_socket_write_err_(errno) != APIError::WOULD_BLOCK) + return APIError::SOCKET_WRITE_FAILED; + } } // If backlog is clear, try direct send @@ -125,6 +127,7 @@ APIError APIFrameHelper::write_raw_(const struct iovec *iov, int iovcnt, uint16_ (iovcnt == 1) ? this->socket_->write(iov[0].iov_base, iov[0].iov_len) : this->socket_->writev(iov, iovcnt); if (sent == -1) [[unlikely]] { + HELPER_LOG("Socket write failed with errno %d", errno); if (this->check_socket_write_err_(errno) != APIError::WOULD_BLOCK) return APIError::SOCKET_WRITE_FAILED; } else if (static_cast(sent) >= total_write_len) [[likely]] {