Merge pull request #1471 from PR0M3TH3AN/ai/debug-frontend-20250222-248801311659160913

fix(ai): frontend console error — remove broken trackers (agent)
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-21 14:08:19 -05:00
commit bf86a98dfa
4 files changed
+54 -32

No files matched your search

-2
View File
@@ -106,9 +106,7 @@ function sanitizeTrustSeedList(candidate) {
const DEFAULT_WSS_TRACKERS = Object.freeze([
"wss://tracker.openwebtorrent.com",
"wss://tracker.ghostchu-services.top:443/announce",
"wss://tracker.files.fm:7073/announce",
"wss://tracker.dler.org:443/announce",
"wss://tracker.btorrent.xyz",
"wss://tracker.novage.com.ua:443/announce",
]);
+29
View File
@@ -55,6 +55,35 @@ export function normalizeAndAugmentMagnet(
didChange = true;
}
// Filter out known broken trackers to prevent console errors
const BROKEN_TRACKERS = [
"wss://tracker.dler.org/announce",
"wss://tracker.dler.org:443/announce",
"wss://tracker.ghostchu-services.top/announce",
"wss://tracker.ghostchu-services.top:443/announce",
];
// We need to filter 'tr' params
// Since we don't have a remove function in shared, we rebuild params if needed
const currentTrackers = params
.filter((p) => p.key === "tr")
.map((p) => p.decoded || p.value);
const hasBroken = currentTrackers.some((t) => BROKEN_TRACKERS.includes(t));
if (hasBroken) {
const validParams = params.filter((p) => {
if (p.key !== "tr") return true;
const val = p.decoded || p.value;
return !BROKEN_TRACKERS.includes(val);
});
// Replace params content
params.length = 0;
params.push(...validParams);
didChange = true;
}
const torrentHint = typeof torrentUrl === "string" && torrentUrl.trim()
? torrentUrl
: typeof xs === "string"
-30
View File
@@ -1,30 +0,0 @@
from playwright.sync_api import sync_playwright
import sys
import time
def run():
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
# Subscribe to console messages
page.on("console", lambda msg: print(f"console:{msg.type}: {msg.text}"))
# Subscribe to uncaught exceptions
page.on("pageerror", lambda exc: print(f"pageerror: {exc}"))
# Subscribe to failed network requests
page.on("requestfailed", lambda req: print(f"requestfailed: {req.url} {req.failure}"))
try:
# Navigate to localhost
page.goto("http://localhost:8000", wait_until="networkidle")
# Wait a bit for async operations
time.sleep(2)
except Exception as e:
print(f"Error navigating: {e}")
finally:
browser.close()
if __name__ == "__main__":
run()
+25
View File
@@ -198,3 +198,28 @@ test("helpers trim fragments from non-magnet values", () => {
"Dropping the fragment should be reflected in didChange"
);
});
test("normalizeAndAugmentMagnet filters out known broken trackers", () => {
const infoHash = "abcdef0123456789abcdef0123456789abcdef01";
const brokenTrackers = [
"wss://tracker.dler.org/announce",
"wss://tracker.ghostchu-services.top/announce"
];
const rawMagnet =
`magnet:?xt=urn:btih:${infoHash}` +
`&tr=${brokenTrackers[0]}` +
`&tr=${brokenTrackers[1]}`;
const result = normalizeMagnetObject(rawMagnet);
const trackers = getParamValues(result.magnet, "tr");
for (const broken of brokenTrackers) {
assert.ok(
!trackers.includes(broken),
`Expected broken tracker ${broken} to be removed`
);
}
assertDefaultTrackersPresent(result.magnet);
});