Skip to content

Commit cf0e8d2

Browse files
committed
fix: keep native log container id in sync when Swarm/compose replaces it
Closes Dokploy#5134. The container list queries in the Logs tab only fetched once on mount, so if the underlying container was replaced (restart, reschedule, redeploy) while the page stayed open, the native log WebSocket kept streaming from the stale id and either froze or failed with 'No such container'. Poll the container list every 5s and reconcile the selected id against it, matching the pattern already used for automatic selection.
1 parent 5b6a8bd commit cf0e8d2

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎apps/dokploy/components/dashboard/compose/logs/show-stack.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const ShowDockerLogsStack = ({
5555
},
5656
{
5757
enabled: !!appName && option === "swarm",
58+
refetchInterval: 5000,
5859
},
5960
);
6061

@@ -67,6 +68,7 @@ export const ShowDockerLogsStack = ({
6768
},
6869
{
6970
enabled: !!appName && option === "native",
71+
refetchInterval: 5000,
7072
},
7173
);
7274

‎apps/dokploy/components/dashboard/compose/logs/show.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Loader2 } from "lucide-react";
22
import dynamic from "next/dynamic";
33
import { useEffect, useState } from "react";
44
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
5+
import { resolveContainerSelection } from "@/components/dashboard/docker/logs/utils";
56
import { Badge } from "@/components/ui/badge";
67
import {
78
Card,
@@ -52,14 +53,15 @@ export const ShowDockerLogsCompose = ({
5253
},
5354
{
5455
enabled: !!appName,
56+
refetchInterval: 5000,
5557
},
5658
);
5759
const [containerId, setContainerId] = useState<string | undefined>();
5860

5961
useEffect(() => {
60-
if (data && data?.length > 0) {
61-
setContainerId(data[0]?.containerId);
62-
}
62+
setContainerId((currentContainerId) =>
63+
resolveContainerSelection(currentContainerId, data),
64+
);
6365
}, [data]);
6466

6567
return (

0 commit comments

Comments
 (0)