refactor: resilient integration queries + simplification
- Extract settleIntegrationQueries helper (Promise.allSettled + logging) so one failing integration no longer kills the entire widget - Convert 16 widget routers from Promise.all to settleIntegrationQueries - Add onSettled query invalidation to downloads and media-requests mutations - Inline 4 single-use firewall useUpdating* hooks - Deduplicate firewall router (4 identical procedures → shared factory) - Fix system-resources chart duplicate initial point (ref-based dedup) - Simplify docker table refresh (refetch + isFetching, drop manual state) - Trim invalidateIntegrationCacheAsync to session-store only (dead scan) - Fix Beszel getAlerts: inner Promise.allSettled so systems failure doesn't discard alerts
This commit is contained in:
24 files changed
+242
-408
No files matched your search
@@ -3,6 +3,7 @@ import { notificationsRequestHandler } from "@homarr/request-handler/notificatio
|
||||
|
||||
import type { IntegrationAction } from "../../middlewares/integration";
|
||||
import { createManyIntegrationMiddleware } from "../../middlewares/integration";
|
||||
import { settleIntegrationQueries } from "../../settle-integrations";
|
||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
||||
|
||||
const createNotificationsIntegrationMiddleware = (action: IntegrationAction) =>
|
||||
@@ -12,21 +13,19 @@ export const notificationsRouter = createTRPCRouter({
|
||||
getNotifications: publicProcedure
|
||||
.unstable_concat(createNotificationsIntegrationMiddleware("query"))
|
||||
.query(async ({ ctx }) => {
|
||||
return await Promise.all(
|
||||
ctx.integrations.map(async (integration) => {
|
||||
const innerHandler = notificationsRequestHandler.handler(integration, {});
|
||||
const { data, timestamp } = await innerHandler.getDataAsync();
|
||||
return await settleIntegrationQueries(ctx.integrations, async (integration) => {
|
||||
const innerHandler = notificationsRequestHandler.handler(integration, {});
|
||||
const { data, timestamp } = await innerHandler.getDataAsync();
|
||||
|
||||
return {
|
||||
integration: {
|
||||
id: integration.id,
|
||||
name: integration.name,
|
||||
kind: integration.kind,
|
||||
updatedAt: timestamp,
|
||||
},
|
||||
data,
|
||||
};
|
||||
}),
|
||||
);
|
||||
return {
|
||||
integration: {
|
||||
id: integration.id,
|
||||
name: integration.name,
|
||||
kind: integration.kind,
|
||||
updatedAt: timestamp,
|
||||
},
|
||||
data,
|
||||
};
|
||||
});
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user