mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
fix(test): add debug logging and increase timeout in webtorrent regression test
- Increase `timeoutMs` in `tests/webtorrent-regression.test.mjs` from 50ms to 200ms to reduce flakiness in CI environments. - Add debug logging to `js/webtorrent.js` (guarded by `NODE_ENV === 'test'`) to inspect `probePeers` inputs and `client.add` errors, helping diagnose why `webseedOnly` detection might fail in CI. - Log failure details in `tests/webtorrent-regression.test.mjs` if assertion fails. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
060e87dada
commit
80dd5dcade
2 files changed
+17
-1
No files matched your search
@@ -207,6 +207,11 @@ export class TorrentClient {
|
||||
magnetURI,
|
||||
{ timeoutMs = 8000, maxWebConns = 2, polls = 2, urlList = [] } = {}
|
||||
) {
|
||||
// Debug log for CI investigation
|
||||
if (typeof process !== "undefined" && process.env.NODE_ENV === "test") {
|
||||
console.log(`[probePeers] magnetURI=${magnetURI?.substring(0, 20)}... urlList=${JSON.stringify(urlList)}`);
|
||||
}
|
||||
|
||||
const magnet = stripXsParameter(magnetURI);
|
||||
|
||||
if (!magnet) {
|
||||
@@ -228,6 +233,10 @@ export class TorrentClient {
|
||||
const hasMagnetWebSeed = magnet.includes("ws=") || magnet.includes("webSeed=");
|
||||
const hasExplicitWebSeed = Array.isArray(urlList) && urlList.length > 0;
|
||||
|
||||
if (typeof process !== "undefined" && process.env.NODE_ENV === "test") {
|
||||
console.log(`[probePeers] hasMagnetWebSeed=${hasMagnetWebSeed} hasExplicitWebSeed=${hasExplicitWebSeed}`);
|
||||
}
|
||||
|
||||
if (hasExplicitWebSeed) {
|
||||
const wsParams = urlList
|
||||
.map((url) => `ws=${encodeURIComponent(url)}`)
|
||||
@@ -336,6 +345,9 @@ export class TorrentClient {
|
||||
}
|
||||
torrent = client.add(augmentedMagnet, addOptions);
|
||||
} catch (err) {
|
||||
if (typeof process !== "undefined" && process.env.NODE_ENV === "test") {
|
||||
console.log(`[probePeers] client.add threw:`, err);
|
||||
}
|
||||
finalize({
|
||||
reason: "error",
|
||||
error: toError(err),
|
||||
|
||||
@@ -62,10 +62,14 @@ describe("WebTorrent Regression Tests", () => {
|
||||
const webSeedUrl = "http://localhost:8080/video.mp4";
|
||||
|
||||
const result = await client.probePeers(magnet, {
|
||||
timeoutMs: 50, // Short timeout
|
||||
timeoutMs: 200, // Short timeout (but safe for CI)
|
||||
urlList: [webSeedUrl]
|
||||
});
|
||||
|
||||
if (!result.webseedOnly) {
|
||||
console.log("Failed result:", result);
|
||||
}
|
||||
|
||||
assert.strictEqual(result.webseedOnly, true, "Should detect webseed only scenario");
|
||||
assert.strictEqual(result.healthy, true, "Should be healthy due to webseed");
|
||||
assert.strictEqual(result.reason, "webseed", "Reason should be 'webseed'");
|
||||
|
||||
Reference in new issue
Block a user