Skip to content

web: fix NetworkError on device-name save & reboot - #455

Merged
Variour merged 1 commit into
mainfrom
claude/device-name-save-network-error-tr9ivb
Jul 25, 2026
Merged

web: fix NetworkError on device-name save & reboot#455
Variour merged 1 commit into
mainfrom
claude/device-name-save-network-error-tr9ivb

Conversation

@Variour

@Variour Variour commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug: changing the device name (or OTA port/enabled, or the I2C bus/expander), clicking Save & Reboot, shows "Save failed: NetworkError when attempting to fetch resource" even though the config was actually saved — confirmed by reloading the page.
  • Root cause: _postConfig sent the response then called delay(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.
  • Fix: the response now sets Connection: close and defers ESP.restart() to the request's onDisconnect callback, 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.h passes (verified locally)
  • On device: change the device name, click Save & Reboot, confirm no "Save failed" error appears and the "Waiting for device… / Device is back online!" flow completes normally
  • On device: repeat for an OTA port/enabled change and an I2C bus/expander change (same code path)

Generated by Claude Code

@Variour Variour added the bug Something isn't working label Jul 24, 2026 — with Claude
…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
Variour force-pushed the claude/device-name-save-network-error-tr9ivb branch from 866b93d to 4fbe80a Compare July 25, 2026 08:32
@Variour
Variour merged commit ce57932 into main Jul 25, 2026
10 checks passed
@Variour
Variour deleted the claude/device-name-save-network-error-tr9ivb branch July 25, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants