[esphome] Fix OTA backend abort not being called on error (#13182)

This commit is contained in:
J. Nick Koston authored and Jonathan Swoboda committed 2026-01-13 11:01:21 -05:00
1 parent 9504e92458
commit d6507ce329
1 file changed
+3 -1
@@ -395,12 +395,14 @@ void ESPHomeOTAComponent::handle_data_() {
error:
this->write_byte_(static_cast<uint8_t>(error_code));
this->cleanup_connection_();
// Abort backend before cleanup - cleanup_connection_() destroys the backend
if (this->backend_ != nullptr && update_started) {
this->backend_->abort();
}
this->cleanup_connection_();
this->status_momentary_error("err", 5000);
#ifdef USE_OTA_STATE_CALLBACK
this->state_callback_.call(ota::OTA_ERROR, 0.0f, static_cast<uint8_t>(error_code));