Skip to content

Commit e719c2d

Browse files
committed
fix(trigger): keep each worker's egress gateway address out of the env sync
The Trigger.dev env sync copies the app's OUTBOUND_GATEWAYS over the worker value. The app reaches a gateway through the VPC load balancer; workers reach it through their own private endpoint, so the copied URL is unreachable from a run and every gateway-routed request in a background run fails with GATEWAY_UNAVAILABLE after two connect timeouts. OUTBOUND_GATEWAYS is now Trigger-owned like REDIS_URL; the shared credentials and routing source still sync.
1 parent 66d461d commit e719c2d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎packages/runtime-secrets/src/trigger-env.test.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
import { describe, expect, it } from 'vitest'
2-
import { parseTriggerEnvSyncTargets } from './trigger-env'
2+
import { buildTriggerEnvVars, parseTriggerEnvSyncTargets } from './trigger-env'
3+
4+
describe('buildTriggerEnvVars', () => {
5+
it('leaves the worker-specific network endpoints to the Trigger.dev environment', () => {
6+
const synced = buildTriggerEnvVars({
7+
REDIS_URL: 'rediss://vpc-redis:6379',
8+
INTERNAL_API_BASE_URL: 'http://app.internal',
9+
OUTBOUND_GATEWAYS: '{"gw":{"url":"https://vpc-lb:8443"}}',
10+
OUTBOUND_GATEWAY_CREDENTIALS: '{"gw":{"token":"t"}}',
11+
OUTBOUND_ROUTING_SOURCE: 'appconfig',
12+
}).map((v) => v.name)
13+
expect(synced).not.toContain('REDIS_URL')
14+
expect(synced).not.toContain('INTERNAL_API_BASE_URL')
15+
expect(synced).not.toContain('OUTBOUND_GATEWAYS')
16+
expect(synced).toContain('OUTBOUND_GATEWAY_CREDENTIALS')
17+
expect(synced).toContain('OUTBOUND_ROUTING_SOURCE')
18+
})
19+
})
320

421
describe('parseTriggerEnvSyncTargets', () => {
522
it('reads an exact comma list', () => {

‎packages/runtime-secrets/src/trigger-env.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const TRIGGER_OWNED_KEYS: ReadonlySet<string> = new Set([
2626
'REDIS_TLS_SERVERNAME',
2727
// A VPC-internal base URL is unreachable from Trigger.dev's cloud.
2828
'INTERNAL_API_BASE_URL',
29+
// The app dials an egress gateway through the VPC load balancer; workers dial it through their
30+
// own endpoint, so each gateway's `url` differs. The credentials and routing source are shared.
31+
'OUTBOUND_GATEWAYS',
2932
// Schema-migration credential: runs never migrate, so they never hold it.
3033
'MIGRATION_DATABASE_URL',
3134
// `syncEnvVars` refuses to sync it, so it can only ever be set by hand.

0 commit comments

Comments
 (0)