From bf7988226d46553ed97c217cb4b004802a739b1c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:14:30 +0000 Subject: [PATCH] Fix WebTorrent client race condition and silence legacy avatar warning - Added a null check for `this.client` in `js/webtorrent.js` after `await this.init()` to prevent `TypeError` when cleanup occurs during initialization. - Updated `js/utils/profileMedia.js` to silently ignore the legacy `images/robot.png` path, preventing "Unsupported media URL" warnings. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/utils/profileMedia.js | 4 ++++ js/webtorrent.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/js/utils/profileMedia.js b/js/utils/profileMedia.js index 07cb2dfd..4de331ed 100644 --- a/js/utils/profileMedia.js +++ b/js/utils/profileMedia.js @@ -46,6 +46,10 @@ export function sanitizeProfileMediaUrl(value) { return trimmed; } + if (trimmed === "images/robot.png") { + return ""; + } + if (/^ipfs:\/\//i.test(trimmed)) { return normalizeIpfsGatewayUrl(trimmed); } diff --git a/js/webtorrent.js b/js/webtorrent.js index 84dbaf38..dce6785c 100644 --- a/js/webtorrent.js +++ b/js/webtorrent.js @@ -873,6 +873,11 @@ export class TorrentClient { emit("torrent-stream-start", { magnet: magnetURI }); // 1) Make sure we have a WebTorrent client and a valid SW registration. const initResult = await this.init(); + + if (!this.client) { + throw new Error("Client destroyed during initialization"); + } + const serviceWorkerReady = !!(initResult?.serviceWorkerReady && this.swRegistration);