From c8497912ba8486e07d197f43581d2bdcbd5058d8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 6 Nov 2026 13:44:03 +0100 Subject: [PATCH] fix(terminal): turn off the idle limit by default A long command without output (for example pg_restore) was ended after 30 minutes. Sessions still end on lost access and at the maximum duration. --- docker/coolify-terminal/terminal-server.js | 2 +- docker/coolify-terminal/terminal-server.test.js | 8 +++----- docker/coolify-terminal/terminal-utils.js | 7 +++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docker/coolify-terminal/terminal-server.js b/docker/coolify-terminal/terminal-server.js index 4939cfb070..2db03a86ad 100755 --- a/docker/coolify-terminal/terminal-server.js +++ b/docker/coolify-terminal/terminal-server.js @@ -519,7 +519,7 @@ function watchTerminalSession(userSession, ptyProcess, terminalSessionId) { return; } - if (Date.now() - userSession.lastActivityAt >= TERMINAL_IDLE_TIMEOUT_SECONDS * 1000) { + if (TERMINAL_IDLE_TIMEOUT_SECONDS > 0 && Date.now() - userSession.lastActivityAt >= TERMINAL_IDLE_TIMEOUT_SECONDS * 1000) { await endTerminalSession(userSession, ptyProcess, 'idle', `no input or output for ${TERMINAL_IDLE_TIMEOUT_SECONDS / 60} minutes.`); return; } diff --git a/docker/coolify-terminal/terminal-server.test.js b/docker/coolify-terminal/terminal-server.test.js index 46a3dc4000..bd1206940a 100644 --- a/docker/coolify-terminal/terminal-server.test.js +++ b/docker/coolify-terminal/terminal-server.test.js @@ -167,12 +167,10 @@ test('input keeps a session without output alive', async () => { assert.deepEqual(session.ends, []); }); -test('a session with no input and no output ends after the idle timeout', async () => { +test('a session with no input and no output is not ended as idle by default', async () => { const session = await startWatchedSession(); await session.at(10, session.output); - await session.at(39, session.tick); - assert.deepEqual(session.ends, []); + await session.at(7 * 60, session.tick); - await session.at(40, session.tick); - assert.deepEqual(session.ends, ['idle']); + assert.deepEqual(session.ends, []); }); diff --git a/docker/coolify-terminal/terminal-utils.js b/docker/coolify-terminal/terminal-utils.js index d8280e7742..b679944b94 100644 --- a/docker/coolify-terminal/terminal-utils.js +++ b/docker/coolify-terminal/terminal-utils.js @@ -2,8 +2,11 @@ import { parseCookie } from 'cookie'; export const MAX_TERMINAL_SESSION_TIMEOUT_SECONDS = 8 * 60 * 60; -/** A PTY with no input and no output for this long is ended. */ -export const TERMINAL_IDLE_TIMEOUT_SECONDS = 30 * 60; +/** + * A PTY with no input and no output for this long is ended. 0 turns the idle limit off, so a + * long command without output (for example a restore) keeps running until the maximum duration. + */ +export const TERMINAL_IDLE_TIMEOUT_SECONDS = 0; /** How often each live PTY checks with Coolify that the user may still use it. */ export const TERMINAL_SESSION_CHECK_INTERVAL_MS = 60 * 1000;