fix(webtorrent): ensure webseed-only streams are marked healthy

Previously, `probePeers` would mark a stream as unhealthy (healthy: false) if no P2P peers were found, even if a valid webseed was present. This caused the UI to potentially disable playback or show error states for webseed-only content.

This fix ensures that if `peers === 0` but `hasWebSeed` is true, the probe result returns `healthy: true` with reason `"webseed"`.

Added `tests/webtorrent-regression.test.mjs` to verify this behavior and prevent future regressions.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-31 19:07:31 +00:00
1 parent 1dd379577f
commit 9aaf8aa4d5
2 files changed
+98 -6

No files matched your search

+8 -6
View File
@@ -346,23 +346,25 @@ export class TorrentClient {
torrent.once("error", (err) => {
const peers = Math.max(0, Math.floor(normalizeNumber(torrent?.numPeers, 0)));
const webseedOnly = peers === 0 && hasWebSeed;
finalize({
healthy: false,
reason: "error",
healthy: webseedOnly,
reason: webseedOnly ? "webseed" : "error",
error: toError(err),
peers,
webseedOnly: peers === 0 && hasWebSeed,
webseedOnly,
});
});
if (safeTimeout > 0) {
timeoutId = setTimeout(() => {
const peers = Math.max(0, Math.floor(normalizeNumber(torrent?.numPeers, 0)));
const webseedOnly = peers === 0 && hasWebSeed;
finalize({
healthy: false,
healthy: webseedOnly,
peers,
reason: "timeout",
webseedOnly: peers === 0 && hasWebSeed,
reason: webseedOnly ? "webseed" : "timeout",
webseedOnly,
});
}, safeTimeout);
}