diff --git a/apps/dokploy/components/shared/maintenance-overlay.tsx b/apps/dokploy/components/shared/maintenance-overlay.tsx
new file mode 100644
index 000000000..e0f131e63
--- /dev/null
+++ b/apps/dokploy/components/shared/maintenance-overlay.tsx
@@ -0,0 +1,58 @@
+import { Loader2 } from "lucide-react";
+import { useEffect, useState } from "react";
+import { cn } from "@/lib/utils";
+
+const HEALTH_URL = "/api/health";
+const POLL_HEALTHY_MS = 15000;
+const POLL_DOWN_MS = 2000;
+
+/**
+ * Polls the panel's readiness probe (/api/health) and shows a slim, non-blocking
+ * banner while the panel is unreachable — e.g. during a self-update (Nomad canary
+ * roll) when Traefik briefly has no healthy backend and returns 502/503. The
+ * banner auto-clears as soon as the panel answers again. It never traps the user
+ * in a full-screen modal; the rest of the UI stays usable while requests retry.
+ */
+export const MaintenanceOverlay = () => {
+ const [down, setDown] = useState(false);
+
+ useEffect(() => {
+ if (typeof window === "undefined") return;
+
+ let cancelled = false;
+
+ const check = async () => {
+ try {
+ const res = await fetch(HEALTH_URL, { cache: "no-store" });
+ if (!cancelled) setDown(!res.ok);
+ } catch {
+ if (!cancelled) setDown(true);
+ }
+ };
+
+ // Run one check immediately, then poll faster while down so recovery is quick.
+ void check();
+ const interval = setInterval(check, down ? POLL_DOWN_MS : POLL_HEALTHY_MS);
+
+ return () => {
+ cancelled = true;
+ clearInterval(interval);
+ };
+ }, [down]);
+
+ if (!down) return null;
+
+ return (
+
+ );
+};
diff --git a/apps/dokploy/pages/_app.tsx b/apps/dokploy/pages/_app.tsx
index df3411151..16aed8e49 100644
--- a/apps/dokploy/pages/_app.tsx
+++ b/apps/dokploy/pages/_app.tsx
@@ -9,6 +9,7 @@ import NextTopLoader from "nextjs-toploader";
import type { ReactElement, ReactNode } from "react";
import { SearchCommand } from "@/components/dashboard/search-command";
import { WhitelabelingProvider } from "@/components/proprietary/whitelabeling/whitelabeling-provider";
+import { MaintenanceOverlay } from "@/components/shared/maintenance-overlay";
import { Toaster } from "@/components/ui/sonner";
import { api } from "@/utils/api";
@@ -49,6 +50,7 @@ const MyApp = ({
forcedTheme={Component.theme}
>
+
diff --git a/apps/dokploy/utils/api.ts b/apps/dokploy/utils/api.ts
index d7f165f6a..4d9af7b63 100644
--- a/apps/dokploy/utils/api.ts
+++ b/apps/dokploy/utils/api.ts
@@ -3,6 +3,7 @@ import {
httpBatchLink,
httpLink,
splitLink,
+ TRPCClientError,
wsLink,
} from "@trpc/client";
import { createTRPCNext } from "@trpc/next";
@@ -10,6 +11,26 @@ import type { inferRouterInputs, inferRouterOutputs } from "@trpc/server";
import superjson from "superjson";
import type { AppRouter } from "@/server/api/root";
+/**
+ * Transient failures are the ones worth retrying during a panel self-update
+ * (a Nomad canary roll). While Traefik has no healthy backend it returns
+ * 502/503/504, and in-flight requests may fail at the network layer before
+ * they ever reach the server. Those should be retried so the user's action
+ * survives the cutover. Real 4xx errors (400/401/403/404) are never retried.
+ */
+export const isTransientError = (error: unknown): boolean => {
+ if (error instanceof TRPCClientError) {
+ const status = (error as TRPCClientError).data?.httpStatus;
+ if (typeof status === "number") {
+ return status >= 500;
+ }
+ // No tRPC error shape at all (network/parse failure mid-cutover).
+ return true;
+ }
+ // Plain Error/TypeError from a failed fetch — treat as a network failure.
+ return true;
+};
+
const getBaseUrl = () => {
if (typeof window !== "undefined") return "";
return `http://localhost:${process.env.PORT ?? 3000}`;
@@ -73,7 +94,28 @@ const links =
export const api = createTRPCNext({
config() {
- return { links };
+ return {
+ links,
+ // Retry only transient failures (see isTransientError) so a user's
+ // action survives the panel self-update cutover (Traefik 502/503/504
+ // or an outright network failure while no backend is healthy).
+ // NB: in @trpc/next v11 this lives inside the config() return value
+ // (it's forwarded to the internal QueryClient), not alongside config().
+ queryClientConfig: {
+ defaultOptions: {
+ queries: {
+ retry: (count, err) => count < 5 && isTransientError(err),
+ retryDelay: (count) => Math.min(1000 * 2 ** count, 5000),
+ },
+ mutations: {
+ // A 502 at the LB means the mutation never reached the server,
+ // so retrying is safe for the panel-roll cutover case.
+ retry: (count, err) => count < 3 && isTransientError(err),
+ retryDelay: (count) => Math.min(1000 * 2 ** count, 5000),
+ },
+ },
+ },
+ };
},
ssr: false,
transformer: superjson,