From c8f00da7e9f20a3d1f1d965834723ac60a7fc6d8 Mon Sep 17 00:00:00 2001 From: Davi de Carvalho Date: Fri, 16 Oct 2026 10:30:41 -0300 Subject: [PATCH] fix: do not create the transport during warmup A warmed up app never gets started and its providers are never shut down. Creating the transport (for example, redis) opens connections that nothing closes, which keeps the process alive after commands like "node ace codegen" terminate the app. Co-Authored-By: Claude Opus 5.5 --- providers/transmit_provider.ts | 13 ++++++++++--- tests/provider.spec.ts | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/providers/transmit_provider.ts b/providers/transmit_provider.ts index 38941bf..a5137a1 100644 --- a/providers/transmit_provider.ts +++ b/providers/transmit_provider.ts @@ -20,12 +20,19 @@ export default class TransmitProvider { this.app.container.singleton('transmit', async () => { const router = await this.app.container.make('router') const config = this.app.config.get('transmit', {}) - const transmitConfig: TransmitConfig = - this.app.getMode() === 'warmup' ? { ...config, pingInterval: false } : config + const isWarmingUp = this.app.getMode() === 'warmup' + const transmitConfig: TransmitConfig = isWarmingUp + ? { ...config, pingInterval: false } + : config let transport: Transport | null = null - if (config.transport) { + /** + * A warmed up app never gets started and its providers are never shut + * down. Therefore, we must not create the transport (and open its + * connections) in this mode. + */ + if (config.transport && !isWarmingUp) { transport = config.transport.driver() } diff --git a/tests/provider.spec.ts b/tests/provider.spec.ts index 6430f40..a7ca4ab 100644 --- a/tests/provider.spec.ts +++ b/tests/provider.spec.ts @@ -42,6 +42,30 @@ test.group('Provider', () => { assert.equal(driverCalls, 1) }) + test('should not call transport driver in warmup mode', async ({ assert }) => { + let driverCalls = 0 + + const app = await setupApp('console', { + transmit: defineConfig({ + pingInterval: false, + transport: { + driver: () => { + driverCalls++ + return null + }, + } as any, + }), + }) + app.getMode = () => 'warmup' + + const transmit = await app.container.make('transmit') + transmit.authorize('/channels/:id', () => true) + + assert.equal(driverCalls, 0) + + await app.terminate() + }) + test('should not start the ping interval in warmup mode', async ({ assert }) => { const app = await setupApp('console', { transmit: defineConfig({