Skip to content

miso serve/dev: don't stall on idle browser connections - #26

Merged
dmjio merged 1 commit into
mainfrom
serve-idle-connections
Oct 22, 2026
Merged

dmjio merged 1 commit into
mainfrom
serve-idle-connections

Conversation

@dmjio

@dmjio dmjio commented Oct 22, 2026

Copy link
Copy Markdown
Member

miso dev could stop serving and rebuilding. The server accepted a connection and read from it straight away, with no timeout. Browsers open connections ahead of time (preconnect) and may send nothing on them for seconds. Until the browser sent a request or gave up, the server answered nothing else, and miso dev didn't notice changes or rebuild.

Now accepted connections wait in the select set alongside the listener and are read only once their request arrives. A connection that stays silent for 30 seconds is closed.

Checked with the built tool (miso serve):

Before After
a page request while one connection is open and silent no answer within 8 s answered in 0.03 s
100 parallel requests with 5 silent connections open — all 200, in 0.4 s

404, .. traversal (plain and %2e%2e), HEAD and POST answer as before.

Also: read_file now checks ftell, which returns -1 for a file it can't seek, before allocating the file's size.


Generated by Claude Code

The server accepted a connection and read it at once, waiting with no
timeout.  Browsers open connections ahead of time (preconnect) and may
send nothing on them for seconds; until the browser sent a request or
gave up, the server answered nothing else, and miso dev did not notice
changes or rebuild.  With one idle connection open, a page did not load
within 8 seconds.

Accepted connections now wait in the select set with the listener and
are read when their request arrives; one silent for 30 seconds is
closed.  With five idle connections open, 100 parallel requests are
answered in 0.4 s.

Also: read_file checks ftell, which returns -1 for a file it cannot
seek, before allocating its size.
@dmjio
dmjio merged commit 6cb28ac into main Oct 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant