- Core in src/main.ts: manual SDP copy/paste exchange (default, no tracker) and optional WebTorrent tracker signaling, STUN opt-out - Fingerprint security check, sender confirms before sending - ICE gathering stops after the first STUN result (5 s hard cap) - Receiver writes to OPFS via an inline dedicated worker instead of RAM - Playwright e2e suite across Chromium/Firefox and all signaling modes, opt-in 2.5 GiB transfer test (pnpm test:large) - TODO.md with review findings and the service worker plan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
2.9 KiB
Markdown
58 lines
2.9 KiB
Markdown
# TODO
|
|
|
|
## Next: service worker streaming download
|
|
|
|
Stream received bytes straight into the browser's download manager instead of staging them in OPFS.
|
|
Needs one new file (service workers can only be registered from a real same-origin script).
|
|
|
|
- Removes the OPFS staging copy, so the file no longer takes twice the disk space.
|
|
- Removes the OPFS quota cap (~10 GiB per site, 2000 MiB in Chromium incognito).
|
|
- Fixes "Opening another tab breaks existing downloads" below completely.
|
|
|
|
## Review findings
|
|
|
|
### [P2] Opening another tab breaks existing downloads
|
|
|
|
`clearStorage()` runs on startup and deletes every OPFS entry. OPFS is shared by all tabs of the
|
|
origin, so it also deletes the file behind another tab's not yet clicked download link.
|
|
|
|
- Real fix: Web Locks. Each tab holds a lock named after every file it received (released by the
|
|
browser when the tab closes or crashes). Cleanup only removes entries whose lock is free
|
|
(`navigator.locks.request(name, { ifAvailable: true }, ...)`).
|
|
- Fixed by the service worker download: no OPFS staging, nothing to clean up.
|
|
|
|
### [P2] Disk writes have no flow control
|
|
|
|
Chunks go data channel → main thread → worker message queue → disk without waiting for writes. If
|
|
storage is slower than the network (SD card, HDD, throttled background tab), queued buffers grow
|
|
without bound in RAM.
|
|
|
|
- Real fix: application level acknowledgements. The receiving side cannot pause a data channel,
|
|
so the worker reports its written offset, the receiver sends it to the sender over the data
|
|
channel, and the sender keeps at most a fixed window (e.g. 8 MiB) unacknowledged, on top of the
|
|
existing `bufferedAmount` check.
|
|
- Not fixed by the service worker: stream backpressure stops at the receiver, it still has to
|
|
reach the sender.
|
|
- Bonus: the acknowledged offset is the basis for resuming interrupted transfers.
|
|
|
|
### [P2] Storage failures don't stop the transfer
|
|
|
|
A write failure is only logged on the receiver. The sender keeps sending and reports "sent", which
|
|
only means "handed to the send buffer".
|
|
|
|
- Real fix:
|
|
1. Check `navigator.storage.estimate()` against the announced size before accepting, optionally
|
|
`navigator.storage.persist()` (raises Firefox's limit after a prompt).
|
|
2. Report errors to the sender (`{ error }` message or closing the channel), sender stops.
|
|
3. Receiver sends "done" only after the final flush, sender shows "delivered" only then.
|
|
- Partly fixed by the service worker: the quota failure goes away, but download errors and user
|
|
cancels still have to be reported to the sender.
|
|
- Points 2 and 3 share the receiver → sender control channel with the flow control fix, build them
|
|
together.
|
|
|
|
## Open observations
|
|
|
|
- `large: firefox sends 2.5 GiB` hit 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.
|