The v1.69.0 caching refactor (f19033e0d) replaced the old Redis pub/sub
push mechanism with a global 30s client-side polling interval. This
caused widgets that previously refreshed every 5s (e.g. health-monitoring,
Dashdot, dns-hole) to only refresh every 30s.
Adds a widgetRefetchIntervalOverrides map in query-cache.ts that maps
tRPC path prefixes to refetch intervals matching the pre-v1.69.0
server-side cacheDuration values. The TRPC provider applies these
overrides via setQueryDefaults after the global default.
Also restores server-side cacheTtlMs on all request handlers to prevent
duplicate upstream API calls between client polls, and adds cacheTtlMs
support to createWidgetRequestHandler.
Beszel handlers are left untouched as they have their own cache handling.
Fixes #6268
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { createLogger } from "@homarr/core/infrastructure/logs";
|
|
import type { IntegrationKindByCategory } from "@homarr/definitions";
|
|
import { createIntegrationAsync } from "@homarr/integrations";
|
|
import type { VpnSummary } from "@homarr/integrations/types";
|
|
|
|
import { createIntegrationRequestHandler } from "./lib/integration-request-handler";
|
|
|
|
const logger = createLogger({ module: "vpnRequestHandler" });
|
|
|
|
export const vpnSummaryHandler = createIntegrationRequestHandler<
|
|
VpnSummary | null,
|
|
IntegrationKindByCategory<"vpn">,
|
|
Record<string, never>
|
|
>({
|
|
async requestAsync(integration, _input) {
|
|
try {
|
|
const integrationInstance = await createIntegrationAsync(integration);
|
|
return await integrationInstance.getSummaryAsync();
|
|
} catch (error) {
|
|
logger.warn("Failed to fetch VPN summary, marking as unavailable", {
|
|
integrationId: integration.id,
|
|
integrationKind: integration.kind,
|
|
error: error instanceof Error ? error.message : String(error),
|
|
});
|
|
return null;
|
|
}
|
|
},
|
|
cacheTtlMs: 300_000,
|
|
});
|