mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-08 13:52:58 +00:00
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:
1 parent
1dd379577f
commit
9aaf8aa4d5
2 files changed
+98
-6
No files matched your search
+8
-6
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user