Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions providers/transmit_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TransmitConfig>('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()
}

Expand Down
24 changes: 24 additions & 0 deletions tests/provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading