Skip to content

Commit 6e67864

Browse files
authored
Merge pull request #3951 from Dokploy/3948-unhandled-rejection-in-gettrustedorigins-crashes-server-on-db-connection-failure
fix: add error handling to trusted origins retrieval in admin service
2 parents 30f061e + 2102840 commit 6e67864

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/server/src/services/admin.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,25 @@ export const getTrustedOrigins = async () => {
135135
if (trustedOriginsCache && now < trustedOriginsCache.expiresAt) {
136136
return trustedOriginsCache.data;
137137
}
138-
const trustedOrigins = await runQuery();
139-
trustedOriginsCache = {
140-
data: trustedOrigins,
141-
expiresAt: now + TRUSTED_ORIGINS_CACHE_TTL_MS,
142-
};
143-
return trustedOrigins;
138+
try {
139+
const trustedOrigins = await runQuery();
140+
trustedOriginsCache = {
141+
data: trustedOrigins,
142+
expiresAt: now + TRUSTED_ORIGINS_CACHE_TTL_MS,
143+
};
144+
return trustedOrigins;
145+
} catch (error) {
146+
console.error("Failed to fetch trusted origins:", error);
147+
return trustedOriginsCache?.data ?? [];
148+
}
144149
}
145150

146-
return runQuery();
151+
try {
152+
return await runQuery();
153+
} catch (error) {
154+
console.error("Failed to fetch trusted origins:", error);
155+
return [];
156+
}
147157
};
148158

149159
export const getTrustedProviders = async () => {

0 commit comments

Comments
 (0)