andrewrk / andrewrk/StaticHttpFileServer

`serve` hangs on multiple TCP connections sending request data out-of-order

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Zig
Stars
67
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Hi, I have found a bug as described in the title. The `serve` command hangs when a client attempts to open multiple connections and decides to send requests out-of-order, which actually seems be the behavior of real web browsers when dealing with multiple calls to the `window.fetch(...)` JS function. I can reproduce it with both the latest Firefox and Chromium.

[This "httptest" repository](https://github.com/Spiffyk/httptest) is a simple reproducer - just clone it, serve it, and open the served `index.html` in a browser. It just runs the `fetch()` function on 10 files filled with zeroes. When everything loads, a paragraph should pop up saying `Loaded all.`. In the current `main` it stays on `Loading...` indefinitely.

[I have a fix ready using `epoll` to make the TCP `accept` and the actual serving asynchronous relatively to each other](https://github.com/Spiffyk/StaticHttpFileServer/tree/epoll), but that limits the `serve` command to Linux, so it's probably not usable as-is? I can open a PR nevertheless, if desirable.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.