Both sides used to contact every STUN server and tracker at once, so each of them learned the IP address and each tracker that A sent to B. Connections now use one STUN server: the first in the list that reports a public address to a throwaway probe connection within 2 s. It stays for the page's lifetime. If a connection gets no address from it, the next connection probes on from the server after it. A probe runs only while a session waits for it and stops once none does, STUN is turned off or the list changes. The sender joins the first tracker that accepts it and moves to the next only once that one rejects it, can't be reached within 10 s or is lost. The receiver walks the list with one offer each and stays where a tracker reports a seeder (complete), which is the sender: it always announces before anyone has the code. Trackers it passed keep its offer. backend/tracker.mjs now sends complete. wss://tracker.pagequit.net comes first in the default trackers, the public ones are fallbacks. TODO.md drops the server tasks, they aren't work on this codebase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.7 KiB
TODO
Ideas
- Resume interrupted transfers: the receiver already reports how much the download manager has
read (
{ read }), which is where a new connection could continue. The browser can't append to a finished or failed download though, so a resume would have to start a new one.
Open observations
-
Firefox ignores an errored service worker response stream: when the sender vanishes, the receiver logs "download failed: connection lost", but the download stays "in progress" until the user cancels it. Closing the stream instead is worse, Firefox then reports the truncated file as complete despite
Content-Length. Chromium fails the download, but only once the connection counts as failed (~16 s), because its data channel never firesclosefor a vanished peer. -
Firefox also saves a truncated file as complete when it stops the service worker in the middle of a download (after 30 s without events). The receiver's pings (
KEEPALIVE) prevent that, covered bylarge: firefox survives a 40 s stall. A browser that stops it anyway would still never show "download complete" or "delivered", only its download manager would be wrong. -
large: firefox sends 2.5 GiBhit the 5 minute timeout once (first run after the normal suite), not reproduced in 3 runs since. The report was lost; the attached logs will show the cause if it happens again. -
boundary: chromium sends an empty filetimed out in the first two full runs afterbackend/'s tests were added (2026-10-25), with empty logs on both sides. It passed alone 8 times, and in 7 full runs since, one of them with a cold Vite cache. The suite without the new tests passed 4 times. Not reproduced, cause unknown.