mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-16 11:25:24 +02:00
fix(templates): add fetch timeout and handle network errors gracefully
Add 10s AbortSignal timeout to all template fetch calls so they fail cleanly instead of hanging indefinitely when templates.dokploy.com is unreachable. Add try/catch to getTags endpoint which was missing error handling, causing a 500 instead of returning an empty list. Closes #4282
This commit is contained in:
@@ -700,11 +700,14 @@ export const composeRouter = createTRPCRouter({
|
||||
getTags: protectedProcedure
|
||||
.input(z.object({ baseUrl: z.string().optional() }))
|
||||
.query(async ({ input }) => {
|
||||
const githubTemplates = await fetchTemplatesList(input.baseUrl);
|
||||
|
||||
const allTags = githubTemplates.flatMap((template) => template.tags);
|
||||
const uniqueTags = _.uniq(allTags);
|
||||
return uniqueTags;
|
||||
try {
|
||||
const githubTemplates = await fetchTemplatesList(input.baseUrl);
|
||||
const allTags = githubTemplates.flatMap((template) => template.tags);
|
||||
return _.uniq(allTags);
|
||||
} catch (error) {
|
||||
console.warn("Failed to fetch template tags:", error);
|
||||
return [];
|
||||
}
|
||||
}),
|
||||
disconnectGitProvider: protectedProcedure
|
||||
.input(apiFindCompose)
|
||||
|
||||
Reference in New Issue
Block a user