fix: restart portal OTA after response completion

This commit is contained in:
2026-09-17 15:12:15 +10:00
parent f1fdeec8ee
commit 3e09958d11
+8 -6
View File
@@ -1003,13 +1003,15 @@ void WiFiManagerHandlers::handleUpdateDone(AsyncWebServerRequest *request) {
return;
}
// AsyncWebServer queues this response and closes the connection only after
// it has completed the response. Restarting from this request callback—or
// merely waiting a guessed interval—can still tear down that TCP exchange.
// Schedule through process() after this particular response disconnects.
request->onDisconnect([this]() {
_wm->_rebootScheduled = true;
_wm->_rebootTime = millis() + _wm->REBOOT_DELAY_MS;
});
sendApiJson(request, 200, jsonApiOtaUpdateSuccess());
// AsyncWebServer queues this response; restarting from the request callback
// tears down its TCP connection before the client can receive the success
// JSON. Let the application's regular process() call perform the same
// delayed restart path used by the other restart-capable portal endpoints.
_wm->_rebootScheduled = true;
_wm->_rebootTime = millis() + _wm->REBOOT_DELAY_MS;
}
void WiFiManagerHandlers::sendApiJson(AsyncWebServerRequest *request, int code, const String& json) {