Skip to content

Commit 55920e9

Browse files
authored
fix(trigger): add isolated-vm support to trigger.dev container builds (#3269)
Scheduled workflow executions running in trigger.dev containers were failing to spawn isolated-vm workers because the native module wasn't available in the container. This caused loop condition evaluation to silently fail and exit after one iteration. - Add isolated-vm to build.external and additionalPackages in trigger config - Include isolated-vm-worker.cjs via additionalFiles for child process spawning - Add fallback path resolution for worker file in trigger.dev environment
1 parent 958dd64 commit 55920e9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

apps/sim/lib/execution/isolated-vm.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,15 @@ function spawnWorker(): Promise<WorkerInfo> {
679679
}
680680

681681
const currentDir = path.dirname(fileURLToPath(import.meta.url))
682-
const workerPath = path.join(currentDir, 'isolated-vm-worker.cjs')
682+
const candidatePaths = [
683+
path.join(currentDir, 'isolated-vm-worker.cjs'),
684+
path.join(process.cwd(), 'lib', 'execution', 'isolated-vm-worker.cjs'),
685+
]
686+
const workerPath = candidatePaths.find((p) => fs.existsSync(p))
683687

684-
if (!fs.existsSync(workerPath)) {
688+
if (!workerPath) {
685689
settleSpawnInProgress()
686-
reject(new Error(`Worker file not found at ${workerPath}`))
690+
reject(new Error(`Worker file not found at any of: ${candidatePaths.join(', ')}`))
687691
return
688692
}
689693

apps/sim/trigger.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { additionalPackages } from '@trigger.dev/build/extensions/core'
1+
import { additionalFiles, additionalPackages } from '@trigger.dev/build/extensions/core'
22
import { defineConfig } from '@trigger.dev/sdk'
33
import { env } from './lib/core/config/env'
44

@@ -15,9 +15,11 @@ export default defineConfig({
1515
},
1616
dirs: ['./background'],
1717
build: {
18+
external: ['isolated-vm'],
1819
extensions: [
20+
additionalFiles({ files: ['./lib/execution/isolated-vm-worker.cjs'] }),
1921
additionalPackages({
20-
packages: ['unpdf', 'pdf-lib'],
22+
packages: ['unpdf', 'pdf-lib', 'isolated-vm'],
2123
}),
2224
],
2325
},

0 commit comments

Comments
 (0)