From b6bda1991939f5a2bdb6a208d1fd1da2ebabb14e Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 3 Jun 2026 23:53:03 -0300 Subject: [PATCH] fix(quality): explicit promise-existence checks + protocol-aware WebDAV URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SonarCloud new-code findings: - combo.ts / sync-models route: `if (cachedPromise)` -> `!= null` (intentional in-flight-promise reuse; explicit existence check, no behaviour change). - ObsidianSourceCard WebDAV URL: inherit window.location.protocol instead of hard-coding http:// (https when behind a TLS proxy) — clears the http hotspot. --- open-sse/services/combo.ts | 2 +- .../dashboard/endpoint/components/ObsidianSourceCard.tsx | 9 +++++---- src/app/api/providers/[id]/sync-models/route.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/open-sse/services/combo.ts b/open-sse/services/combo.ts index 5f6dfa2ee6..88c8c09a35 100644 --- a/open-sse/services/combo.ts +++ b/open-sse/services/combo.ts @@ -1761,7 +1761,7 @@ async function fetchResetAwareQuotaWithCache({ const refresh = () => { const existing = resetAwareQuotaCache.get(cacheKey); - if (existing?.refreshPromise) return existing.refreshPromise; + if (existing?.refreshPromise != null) return existing.refreshPromise; const refreshPromise = fetcher(connectionId, connection) .then((quota) => { diff --git a/src/app/(dashboard)/dashboard/endpoint/components/ObsidianSourceCard.tsx b/src/app/(dashboard)/dashboard/endpoint/components/ObsidianSourceCard.tsx index 820195c091..35c29e502c 100644 --- a/src/app/(dashboard)/dashboard/endpoint/components/ObsidianSourceCard.tsx +++ b/src/app/(dashboard)/dashboard/endpoint/components/ObsidianSourceCard.tsx @@ -165,10 +165,11 @@ export default function ObsidianSourceCard() { }; const getWebdavUrl = (): string => { - if (typeof window === "undefined") return "http:///api/v1/webdav/"; - const host = window.location.hostname; - const port = window.location.port; - return `http://${host}:${port}/api/v1/webdav`; + if (typeof window === "undefined") return "/api/v1/webdav/"; + // Inherit the page protocol (http on localhost, https behind a TLS proxy) + // instead of hard-coding http. + const { protocol, hostname, port } = window.location; + return `${protocol}//${hostname}:${port}/api/v1/webdav`; }; return ( diff --git a/src/app/api/providers/[id]/sync-models/route.ts b/src/app/api/providers/[id]/sync-models/route.ts index b124b34d3c..1d1a9f4a9d 100644 --- a/src/app/api/providers/[id]/sync-models/route.ts +++ b/src/app/api/providers/[id]/sync-models/route.ts @@ -174,7 +174,7 @@ export type EnsureReadyOptions = { }; export async function ensureLoopbackServerReady(opts: EnsureReadyOptions = {}): Promise { - if (__loopbackReadyPromise) return __loopbackReadyPromise; + if (__loopbackReadyPromise != null) return __loopbackReadyPromise; __loopbackReadyPromise = (async () => { const f = opts.fetch ?? fetch; const maxWaitMs = opts.maxWaitMs ?? 30_000;