From 42da1872e77421f60ca33bf4aabf5dbdbb5b23b0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 6 Apr 2026 12:10:33 +0300 Subject: [PATCH] fix(client): crashing due to circular dependency --- apps/client/src/services/server.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/client/src/services/server.ts b/apps/client/src/services/server.ts index bb32b37ac9..a52fa0fd3f 100644 --- a/apps/client/src/services/server.ts +++ b/apps/client/src/services/server.ts @@ -1,8 +1,5 @@ -import { t } from "./i18n.js"; -import toastService from "./toast.js"; import utils, { isShare } from "./utils.js"; import ValidationError from "./validation_error.js"; -import { logError } from "./ws.js"; type Headers = Record; @@ -346,6 +343,10 @@ async function reportError(method: string, url: string, statusCode: number, resp } catch (e) {} } + // Dynamic imports to avoid circular dependency (toast/i18n → app_context → options → server). + const toastService = (await import("./toast.js")).default; + const { t } = await import("./i18n.js"); + const messageStr = (typeof message === "string" ? message : JSON.stringify(message)) || "-"; if ([400, 404].includes(statusCode) && response && typeof response === "object") { @@ -370,7 +371,7 @@ async function reportError(method: string, url: string, statusCode: number, resp t("server.unknown_http_error_content", { statusCode, method, url, message: messageStr }), 15_000); } - logError(`${statusCode} ${method} ${url} - ${message}`); + window.logError(`${statusCode} ${method} ${url} - ${message}`); } }