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.
This commit is contained in:
Andras Bacsai
2026-11-06 13:44:03 +01:00
parent d5ac1ba27e
commit c8497912ba
3 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -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;
}
@@ -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, []);
});
+5 -2
View File
@@ -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;