fix(core): Prevent SSH tunnel cleanup timer from keeping the process alive (no-changelog) (#32146)

This commit is contained in:
Danny Martini
2026-06-11 13:43:08 +00:00
committed by GitHub
parent f637d53500
commit b17b33f56d
2 changed files with 12 additions and 2 deletions
@@ -40,6 +40,12 @@ afterEach(() => {
sshClientsManager.onShutdown();
});
it('should not keep the process alive for the stale-connection cleanup timer', () => {
const { cleanupTimer } = sshClientsManager as unknown as { cleanupTimer: NodeJS.Timeout };
expect(cleanupTimer.hasRef()).toBe(false);
});
describe('getClient', () => {
it('should create a new SSH client', async () => {
const client = await sshClientsManager.getClient(credentials);
@@ -65,8 +65,12 @@ export class SSHClientsManager {
// Close all SSH connections when the process exits
process.on('exit', () => this.onShutdown());
// Regularly close stale SSH connections
this.cleanupTimer = setInterval(() => this.cleanupStaleConnections(), 60 * 1000);
// Regularly close stale SSH connections. Unref'd so this housekeeping
// timer never keeps the process alive on its own: the manager is created
// by every workflow execution, and a referenced interval would block
// process exit until SIGKILL (e.g. single-file integration test runs
// hang after the run completes).
this.cleanupTimer = setInterval(() => this.cleanupStaleConnections(), 60 * 1000).unref();
this.logger = logger.scoped('ssh-client');
}