web: fix NetworkError on device-name save & reboot - #455
Merged
Conversation
…delay A fixed delay() before ESP.restart() raced the async TCP send: over WiFi the response could still be unacked when the reboot tore the stack down, so the browser saw a connection reset instead of the 200 it earned even though the config (e.g. a new device name) had already been saved. Reboot now waits on the request's onDisconnect callback, paired with a Connection: close header, so it only fires once the client has actually received the response. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JRj2Dd1rqgfYLnVwnnD4op
Variour
force-pushed
the
claude/device-name-save-network-error-tr9ivb
branch
from
July 25, 2026 08:32
866b93d to
4fbe80a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_postConfigsent the response then calleddelay(200); ESP.restart();. That fixed delay races the async TCP send — over WiFi the response can still be unacked (or not yet handed to the radio) when the reboot tears the network stack down, so the browser sees a connection reset instead of the 200 it earned.Connection: closeand defersESP.restart()to the request'sonDisconnectcallback, so the reboot only happens once the client has actually received the response and the connection has closed. No change to the{ok, rebooting}response contract, so no mock-server/UI parity updates needed.Test plan
clang-format --dry-run --Werror src/web/WebServer.hpasses (verified locally)Generated by Claude Code