#6259 [Other] serve: web UI static assets randomly fail (connection reset / empty reply) with parallel connections; `Bad file descriptor` in serve.log
open · @mstoebe · 6 comments · View on GitHub
Description
**Environment**
- Strata 0.2.13 (control/engine 0.1.59), macOS 27.2.1, Apple M4 Mac mini 32 GB, Metal engine
- `strata serve --profile ... --host 0.0.0.0 --port 8090` as a LaunchAgent, bundled Python 3.12.15
- Reproduces on 127.0.0.1 and from the LAN. Engine idle at the time of the tests.
**Symptom**
In a browser the web UI / Monitor loads unstyled or without JS (`initChats is not defined`). DevTools shows random `ERR_EMPTY_RESPONSE` / `ERR_CONNECTION_RESET` on `web/*.css|js|svg`. Single `curl` requests return 200.
**Reproduction** (script attached: `strata_web_burst.py`): 6 threads x 40 rounds, GET of the 6 assets referenced by `/` (app.css, app.js, chats-ui.js, chatstore.js, components.css, favicon.svg), count results.
Measured 19.11.2026 after ~1d21h uptime, engine idle:
- 1333 x 200, 83 x ConnectionResetError, 24 x RemoteDisconnected out of 1440 (7.4 % failed)
- Earlier run same day: 90 of 1440 failed (6.3 %)
- Right after the 0.1.59 update (9.11.): 0 of 880 failed. On 0.1.57 after ~3 days uptime: ~15 %. So it may grow with uptime or with the number of served requests/connections; I have not confirmed which.
**serve.log** (2432 occurrences so far):
```
File ".../serve/server.py", line 7492, in handle_one_request
super().handle_one_request()
File ".../http/server.py", line 408, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File ".../socket.py", line 720, in readinto
return self._sock.recv_into(b)
OSError: [Errno 9] Bad file descriptor
```
**What I ruled out**
- Browser, macOS firewall, bundled Python: a stock `ThreadingHTTPServer` on the same Python, backlog 256, same burst test: 0 of 720 failed.
- A reverse proxy does not help; Caddy -> `host.docker.internal:8090` fails the same way (2 of 6 ok), while other services through the same path are fine.
- Browser settings (prefetch/preconnect off) make no difference.
**Hypothesis (unverified)**
The fd is closed by another thread/path while `handle_one_request` still reads from it (e.g. a socket closed by the request-handling or keep-alive logic, or by the `handle_one_request` override at server.py:7492 around watchdogs for disconnected clients). The fact that a fresh process shows 0 failures and later ones do not suggests state that accumulates over time (fd reuse?).
**Workaround:** hard reload until all assets are cached.
[strata_web_burst.py](https://github.com/user-attachments/files/35071187/strata_web_burst.py)Related on this site
Quick links to related pages.