mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-24 23:22:38 +08:00
fix(core): Prevent SSH tunnel cleanup timer from keeping the process alive (no-changelog) (#32146)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user