Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Engine 2.0 (alpha) #1575

Open
wants to merge 335 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
335 commits
Select commit Hold shift + click to select a range
3d95424
Merge remote-tracking branch 'origin/main' into run-engine-2
matt-aitken Oct 25, 2024
e5e7425
Merge remote-tracking branch 'origin/main' into run-engine-2
matt-aitken Nov 4, 2024
90972f5
run engine singleton
nicktrn Nov 4, 2024
8d22cc7
fix engine shutdown and redis errors in tests
nicktrn Nov 4, 2024
41d79ba
move shared test setup to internal package
nicktrn Nov 4, 2024
37e3f12
add run engine errors to should retry helper
nicktrn Nov 4, 2024
a659f9d
add missing consts export
nicktrn Nov 4, 2024
c255592
Latest lockfile
matt-aitken Nov 4, 2024
7388b87
Cleaned up getting the latest snapshot. Started on attempt failures
matt-aitken Nov 4, 2024
c83d6bd
Work on reattempting
matt-aitken Nov 5, 2024
e9062be
Added Waitpoint outputIsError column
matt-aitken Nov 5, 2024
d01b888
Work on dealing with attempts that fail
matt-aitken Nov 5, 2024
3194257
runs triggered via run engine should be V2
nicktrn Nov 5, 2024
c66d3fe
current unmanaged deployment label
nicktrn Nov 5, 2024
79d4432
schema changes
nicktrn Nov 5, 2024
8089397
run engine base service extension
nicktrn Nov 5, 2024
d036d7a
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Nov 5, 2024
2dab2ea
Improved the triggerAndWait test to start the parentRun before trigge…
matt-aitken Nov 5, 2024
8c3cabf
Simplified the tests so there’s less repeated checks, keep them more …
matt-aitken Nov 5, 2024
cb26957
Failed run test passing
matt-aitken Nov 5, 2024
dc4a88c
hidden worker groups
nicktrn Nov 5, 2024
6bb7a4c
feature flag helpers
nicktrn Nov 5, 2024
a7ecfc9
add basic worker package
nicktrn Nov 5, 2024
41eb240
add worker group services
nicktrn Nov 5, 2024
accee54
get master queue from default worker group on trigger
nicktrn Nov 5, 2024
a6a7b40
basic worker api routes
nicktrn Nov 5, 2024
a035ab1
add worker group tests
nicktrn Nov 5, 2024
d36b2d5
Improved attempt completing and made a test for retries
matt-aitken Nov 5, 2024
a958af2
Merge remote-tracking branch 'origin/main' into run-engine-2
matt-aitken Nov 6, 2024
cca3a5b
Add a delayed run test
matt-aitken Nov 6, 2024
8cda15c
rename and implement lastDequeueAt
nicktrn Nov 6, 2024
0160c97
Renamed checkpointThresholdMs, added a stub for createCheckpoint, and…
matt-aitken Nov 6, 2024
dbc28a8
Fix tests
matt-aitken Nov 6, 2024
176407b
rename complete attempt result
nicktrn Nov 6, 2024
5cb1fef
When an attempt fails snapshot goes to “PENDING_EXECUTING”. Fixes for…
matt-aitken Nov 6, 2024
318d3e0
Cancelling a run. Heartbeat function exposed
matt-aitken Nov 6, 2024
29e8228
Cancelling test now includes a running child task
matt-aitken Nov 6, 2024
3668cf5
don't await the unawaitable
nicktrn Nov 6, 2024
a0dcd78
simplify image build and add node-22 runtime
nicktrn Nov 6, 2024
cba4fca
new worker action api routes
nicktrn Nov 6, 2024
b10094f
deprecate several context props
nicktrn Nov 6, 2024
f14aa04
Fix for bad import
matt-aitken Nov 7, 2024
9741512
Test for cancelling a non-executing run
matt-aitken Nov 7, 2024
d6da828
move image ref helper to core
nicktrn Nov 7, 2024
aa9538d
unify bundling more
nicktrn Nov 7, 2024
f7d2c4c
add missing node-22 case
nicktrn Nov 7, 2024
9c93498
Rescheduling test
matt-aitken Nov 7, 2024
a67a874
Made the rescheduling test a bit more robust/harder to fluke
matt-aitken Nov 7, 2024
915e359
fix cli version import
nicktrn Nov 7, 2024
df14586
Use the eventBus to send worker notifications out of the run engine
matt-aitken Nov 7, 2024
7f2ef42
Update the snapshot with the heartbeat time when we receive one, make…
matt-aitken Nov 7, 2024
66256fc
Split the run engine tests into separate files, it was getting too crazy
matt-aitken Nov 7, 2024
391613e
Added some better comments to the prisma schema
matt-aitken Nov 7, 2024
1640bb2
Use nacking when a heartbeat fails before an attempt is created
matt-aitken Nov 7, 2024
bc01fdb
First heartbeat test working
matt-aitken Nov 7, 2024
5c5312f
If something throws when dequeuing a run, nack it (ideally with a val…
matt-aitken Nov 8, 2024
d89c25a
A test when we fail to start runs until the run goes into a SystemFai…
matt-aitken Nov 8, 2024
5bf7596
Updated the Run Engine readme to document some things and capture som…
matt-aitken Nov 8, 2024
71d1cf8
Tweaked some of the text
matt-aitken Nov 8, 2024
b1cb62f
Added a todo to the prisma schema for auto deactivating idempotency k…
matt-aitken Nov 8, 2024
fa06e80
Added heartbeat recoveries when workers are unresponsive (after an at…
matt-aitken Nov 10, 2024
b787408
Added notes about how to detect if we should use the run engine when …
matt-aitken Nov 10, 2024
caa87af
Improved the test so the run recovers, then completely fails after 2 …
matt-aitken Nov 10, 2024
3049e47
When an attempt fails we remove waitpoints blocking the run
matt-aitken Nov 11, 2024
ae9cfbc
Remove todo
matt-aitken Nov 11, 2024
05154aa
Improved comment
matt-aitken Nov 11, 2024
c7db647
Pending cancel heartbeat test
matt-aitken Nov 11, 2024
42843cd
Emit a `runAttemptStarted` event that can be used for sending invocat…
matt-aitken Nov 11, 2024
c3929c2
Added an env queue so we can track the number of queued items
matt-aitken Nov 11, 2024
d40249f
Increase the delay to make the test more robust
matt-aitken Nov 11, 2024
9885749
Added the env queue length guard to triggerTaskV2
matt-aitken Nov 11, 2024
8670edb
Move the queue length function down
matt-aitken Nov 11, 2024
cafb313
Same logic for waitingForDeploy for dev
matt-aitken Nov 11, 2024
485b1b9
Updated the engine readme after speaking to Eric
matt-aitken Nov 11, 2024
4dfcae6
WorkerGroup migrations
matt-aitken Nov 11, 2024
0af6ead
Waitpoint type event -> manual
matt-aitken Nov 11, 2024
b03982b
Increase some of the timeouts in the heartbeat tests more to avoid fl…
matt-aitken Nov 11, 2024
96b3e8e
Manually creating, blocking, and completing waitpoints added to the r…
matt-aitken Nov 11, 2024
64770ce
When blocking a run with a manual waitpoint, you can set a failAfter …
matt-aitken Nov 11, 2024
5232dfd
Added some notes about run flow control. Rate limit, throttle, batchi…
matt-aitken Nov 12, 2024
954c2bd
worker package updates
nicktrn Nov 12, 2024
8484c55
update worker api routes
nicktrn Nov 12, 2024
dba02b5
one trigger service to rule them all
nicktrn Nov 12, 2024
3201424
minor changes to deployments and run pages
nicktrn Nov 12, 2024
513ea90
update helper import
nicktrn Nov 12, 2024
786b035
managed worker secret and other auth improvements
nicktrn Nov 12, 2024
c898fb2
update populate script
nicktrn Nov 12, 2024
0237752
fix webapp builds
nicktrn Nov 12, 2024
9fa3c98
update lockfile
nicktrn Nov 12, 2024
017d8cf
add worker socket
nicktrn Nov 12, 2024
ece3303
deployment service updates
nicktrn Nov 12, 2024
2ebdbf2
use new trigger service in tests
nicktrn Nov 12, 2024
da5226a
correctly lock to unmanaged background worker
nicktrn Nov 12, 2024
232475e
fix worker http client
nicktrn Nov 12, 2024
2cbcbdb
compare core schema enums against db types
nicktrn Nov 12, 2024
6323e7b
Added jsdocs to the redis worker enqueue function
matt-aitken Nov 12, 2024
6625f69
Deal with runs being dequeued where there’s no background worker, wit…
matt-aitken Nov 12, 2024
85f3dab
Added explicit return types to the other dequeue functions
matt-aitken Nov 13, 2024
de9dd66
BatchTaskRun taskidentifier optional, updated unique constraint
matt-aitken Nov 13, 2024
e4cb7fd
DB migration for BatchTaskRun and worker changes
matt-aitken Nov 13, 2024
7f7644f
Added a todo to triggerTask
matt-aitken Nov 13, 2024
7c0befe
Added some notes to the schema making it clear what we’re using for b…
matt-aitken Nov 13, 2024
33fbc2e
Move the emitted event down
matt-aitken Nov 13, 2024
51c4434
Added a batchTrigger test where a BatchTaskRun is created and passed in
matt-aitken Nov 13, 2024
d203c3e
add workers list command
nicktrn Nov 13, 2024
1bf37c9
support a worker group being set as default by multiple projects
nicktrn Nov 13, 2024
5747417
Run test files in sequence
matt-aitken Nov 13, 2024
a2dd5e3
Moved types to a separate file
matt-aitken Nov 13, 2024
12f4fbb
WIP improving the consistency of the return types in the run engine
matt-aitken Nov 13, 2024
766c4ac
Latest lockfile
matt-aitken Nov 13, 2024
f6208de
Wait for duration explicit return type, including the execution result
matt-aitken Nov 13, 2024
0799938
Recheduling returns the updated TaskRun
matt-aitken Nov 13, 2024
77b7d0f
Added a friendlyId to Waitpoints now we’re going to have a public API…
matt-aitken Nov 13, 2024
04dc85f
A couple more return types
matt-aitken Nov 13, 2024
808a6f9
Organized imports
matt-aitken Nov 13, 2024
c71ac30
Added a test for blocking a second parent with the same child run
matt-aitken Nov 14, 2024
6c3c9f0
Modified triggerTaskV2 to work with the new parentRunId/resumeParentO…
matt-aitken Nov 14, 2024
81188eb
Added TaskRun priorityMs column
matt-aitken Nov 14, 2024
5e2f70a
Migration for Waitpoint.friendlyId and TaskRun.priorityMs
matt-aitken Nov 14, 2024
e3d729c
save cli config in pretty format
nicktrn Nov 13, 2024
f6047d5
fix worker schema import
nicktrn Nov 13, 2024
862339a
cli profile switcher and other goodies
nicktrn Nov 14, 2024
31993c4
add missing node-22 cases
nicktrn Nov 14, 2024
a9db8c3
Better description of the priorityMs column
matt-aitken Nov 14, 2024
4f3c51d
Use the priority when enqueuing runs
matt-aitken Nov 14, 2024
683ceb4
Added a test for priorities
matt-aitken Nov 14, 2024
8f87206
create backup before migrating to new config format
nicktrn Nov 18, 2024
4d5f9c0
first eventbus handler to complete successful run spans
nicktrn Nov 19, 2024
5423968
return env vars when starting run attempts
nicktrn Nov 19, 2024
3276d2b
add basic worker events
nicktrn Nov 19, 2024
dc3a2c1
unmanaged worker builds
nicktrn Nov 19, 2024
b3d42d6
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Nov 19, 2024
65f471c
bump worker version
nicktrn Nov 19, 2024
f084df1
update lockfile after worker bump
nicktrn Nov 19, 2024
9003b18
add v2 run cancellation
nicktrn Nov 21, 2024
d11612e
surface master queues in admin view
nicktrn Nov 22, 2024
99a33e8
run engine compatibility flag and deploy scaffold
nicktrn Nov 24, 2024
ac7076b
checkpoint event indexes
nicktrn Nov 24, 2024
66edfe2
shared -> managed worker
nicktrn Nov 24, 2024
f25a971
add snapshot creation debug task events
nicktrn Nov 24, 2024
26a72dd
add worker instance metadata
nicktrn Nov 24, 2024
ffcd387
remove random package.json
nicktrn Nov 24, 2024
9187996
Revert "checkpoint event indexes"
nicktrn Nov 25, 2024
da74e88
managed worker wip
nicktrn Nov 27, 2024
768fc9b
deprecate cli logger warn and error methods
nicktrn Nov 27, 2024
66a0ff9
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Nov 28, 2024
d95a750
add run heartbeat route
nicktrn Nov 28, 2024
a06e270
update run engine zod version
nicktrn Nov 28, 2024
78a3d35
add workload heartbeats
nicktrn Nov 28, 2024
5da5a61
unify run heartbeat methods
nicktrn Nov 28, 2024
bb824df
restore trigger task service router
nicktrn Nov 28, 2024
0a605b6
remove debug log
nicktrn Nov 28, 2024
68a7e33
complete failed run events, fix success output
nicktrn Nov 28, 2024
3058cdd
child event completion on run failure, better logging
nicktrn Nov 28, 2024
3070a9d
fix http client run heartbeat route
nicktrn Nov 28, 2024
5a79e10
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Dec 2, 2024
a73a3eb
update lockfile
nicktrn Dec 2, 2024
515641e
remove rate limit from run engine
nicktrn Dec 2, 2024
3e26ea4
Always display errors before other code blocks in the run overview tab
nicktrn Dec 2, 2024
ff20023
add retry delay spans
nicktrn Dec 2, 2024
a1b545b
resurrect uncaught exception handler
nicktrn Dec 2, 2024
bed6677
run completion handling and retries
nicktrn Dec 2, 2024
8973ccb
fix span presenter v2 engine outputs and errors
nicktrn Dec 2, 2024
6a91584
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Dec 2, 2024
676496a
bump worker version
nicktrn Dec 2, 2024
0631b22
remove retry span attribute bloat
nicktrn Dec 2, 2024
f595ae4
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Dec 3, 2024
f1b4861
bump worker version
nicktrn Dec 3, 2024
7913e39
report invocation usage
nicktrn Dec 3, 2024
1cc0284
bump node-22 image to 22.12.0 require esm
nicktrn Dec 4, 2024
cd0347f
use full node 21 image version tag
nicktrn Dec 4, 2024
b42db7b
use multi-arch images for bun and node
nicktrn Dec 4, 2024
d9db268
remove unmanaged core export and add managed runtime
nicktrn Dec 4, 2024
b9c9c75
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Dec 6, 2024
71f04cf
bump worker version
nicktrn Dec 6, 2024
3fe3c39
Suggested glossary for the RunEngine, TBC
matt-aitken Dec 6, 2024
2635c58
Removed BatchTaskRun changes from this branch, they were done in main
matt-aitken Dec 6, 2024
fb6c33d
Set the BatchTaskRun status to completed when all runs are completed
matt-aitken Dec 6, 2024
7653c22
When dequeuing respect passed in maxResources
matt-aitken Dec 10, 2024
ff369f3
Ported over the new run props: idempotencyKeyExpiresAt, versions, one…
matt-aitken Dec 10, 2024
fcb4e3b
Didn’t hit save… the new props when triggering tasks passed through
matt-aitken Dec 10, 2024
fd58ce6
Idempotency expiration + waitpoint edge case
matt-aitken Dec 11, 2024
d7a9e2b
WIP on creating checkpoint, parking for now
matt-aitken Dec 12, 2024
b95dd63
fix worker routes
nicktrn Dec 9, 2024
d434746
upgrade webapp node types to support generic event emitter
nicktrn Dec 13, 2024
eb69641
separate event bus handler singleton and run failure alerts
nicktrn Dec 13, 2024
8262320
duration waits
nicktrn Dec 13, 2024
05b7e30
fix execution snapshot debug spans
nicktrn Dec 13, 2024
a6d5ec4
task waits
nicktrn Dec 13, 2024
d4a638e
fix event bus types
nicktrn Dec 13, 2024
4d41221
temporary fix for react hook run handle type
nicktrn Dec 13, 2024
d707a94
disable run notifications for now
nicktrn Dec 13, 2024
3cee74c
convert any typecasts to expect errors to more easily fix later
nicktrn Dec 13, 2024
b4739b7
fix webapp types after node types upgrade
nicktrn Dec 13, 2024
c9a51f1
updateEnvConcurrencyLimits across marqs and the runqueue
matt-aitken Dec 13, 2024
9da544e
Pass proper values into the run engine
matt-aitken Dec 13, 2024
ff79a77
RunQueue settings and removed unused rebalancing workers
matt-aitken Dec 13, 2024
03c9899
Remove rebalancing prop
matt-aitken Dec 13, 2024
c84b506
Tidied more things up
matt-aitken Dec 13, 2024
160e219
Update/remove queue limits for MARQS and RunQueue
matt-aitken Dec 13, 2024
086c1bf
taskQueue/concurrencyLimit changes ported back into the RunEngine
matt-aitken Dec 13, 2024
e1177f7
Reworked completing waitpoints to improve performance and reduce race…
matt-aitken Dec 15, 2024
b57e913
Improved test robustness
matt-aitken Dec 15, 2024
ab9e268
Down to a single run lock only when a run is totally unblocked and re…
matt-aitken Dec 15, 2024
872cea3
warm starts, worker notifications, wait fixes
nicktrn Dec 15, 2024
93d2501
Fix for Run Engine poll interval env var
matt-aitken Dec 16, 2024
f572c0f
Expect the waitpoint to be completed quickly
matt-aitken Dec 16, 2024
fb56932
If a run is locked then it’s too late to expire it
matt-aitken Dec 17, 2024
e01288d
Added VALKEY_ env vars and plugged them into the run engine
matt-aitken Dec 17, 2024
4c9e024
Extracted and updated the guard queue function so it can be used when…
matt-aitken Dec 17, 2024
f020acf
Merge remote-tracking branch 'origin/main' into run-engine-2
matt-aitken Dec 17, 2024
f1e2736
Added logging and universal concurrency changes to trigger task v1
matt-aitken Dec 17, 2024
fb433de
Added notes back in
matt-aitken Dec 17, 2024
1238ef7
Bump @trigger.dev/worker to 3.3.7
matt-aitken Dec 17, 2024
2490882
reportInvocationUsage for the runAttemptStarted event
matt-aitken Dec 17, 2024
a24644b
improve execution snapshot span debug span start times
nicktrn Dec 16, 2024
3df8158
Unfriendly IDs
nicktrn Dec 17, 2024
677a2d6
update lockfile
nicktrn Dec 17, 2024
62c03bf
Created a shared determineEngineVersion function
matt-aitken Dec 17, 2024
0b37539
disable unfinished commands
nicktrn Dec 17, 2024
da41728
save new cli config to different location, misc fixes
nicktrn Dec 17, 2024
d3a3951
add basic engine version check via current deploy
nicktrn Dec 17, 2024
476b20f
new run engine will default to node 22 runtime
nicktrn Dec 17, 2024
e155aad
block some actions for projects on previous run engine
nicktrn Dec 18, 2024
23e8d37
fix worker group tests
nicktrn Dec 18, 2024
fb5b2e7
fix triggerAndWait test
nicktrn Dec 18, 2024
f94154a
one typescript version to rule them all
nicktrn Dec 18, 2024
23f3400
redlock type patch
nicktrn Dec 18, 2024
5f07ff2
fix type issues caused by ts-reset
nicktrn Dec 18, 2024
46c79e0
improve cleanup scripts
nicktrn Dec 18, 2024
accf9f7
add missing socket.io dep
nicktrn Dec 18, 2024
0b0b7da
fix run notification handler type
nicktrn Dec 18, 2024
fa8bfc9
fix worker group test again
nicktrn Dec 18, 2024
958c439
generate prisma client for e2e tests
nicktrn Dec 18, 2024
c8f460e
remove worker group tests for now
nicktrn Dec 18, 2024
082644e
prevent image pull rate limits during unit tests
nicktrn Dec 18, 2024
95a7155
increase timeout for queue concurrency limit test
nicktrn Dec 18, 2024
610c95f
generate prisma client for preview release
nicktrn Dec 18, 2024
b1604fb
same node types everywhere
nicktrn Dec 18, 2024
079bd5c
Merge branch 'main' into run-engine-2
matt-aitken Dec 19, 2024
14250d5
Updated engine readme, removed legacy system notes
matt-aitken Dec 19, 2024
56979e6
use default machine preset from platform package
nicktrn Dec 19, 2024
ae6a473
worker instances plural in schema
nicktrn Dec 19, 2024
482a98d
disable pnpm update notifications
nicktrn Dec 20, 2024
d3386e2
return worker group details from connect call
nicktrn Dec 20, 2024
7d382ac
add workers admin route
nicktrn Dec 20, 2024
a759bf7
fix heartbeat route return type
nicktrn Dec 20, 2024
927edea
move deployment labels to core apps
nicktrn Dec 20, 2024
3d21147
refactor run controller env schema
nicktrn Dec 31, 2024
4f954b2
Add firstAttemptStartedAt to TaskRun
matt-aitken Dec 31, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
- name: 📥 Download deps
run: pnpm install --frozen-lockfile --filter trigger.dev...

- name: 📀 Generate Prisma Client
run: pnpm run generate

- name: 🔧 Build v3 cli monorepo dependencies
run: pnpm run build --filter trigger.dev^...

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
- name: 📥 Download deps
run: pnpm install --frozen-lockfile

- name: 📀 Generate Prisma Client
run: pnpm run generate

- name: 🏗️ Build
run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev"

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
node-version: 20.11.1
cache: "pnpm"

# ..to avoid rate limits when pulling images
- name: 🐳 Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: 📥 Download deps
run: pnpm install --frozen-lockfile

Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
link-workspace-packages=false
public-hoist-pattern[]=*prisma*
prefer-workspace-packages=true
prefer-workspace-packages=true
update-notifier=false
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@
"command": "pnpm exec trigger dev",
"cwd": "${workspaceFolder}/references/hello-world",
"sourceMaps": true
},
{
"type": "node-terminal",
"request": "launch",
"name": "Debug RunEngine tests",
"command": "pnpm run test --filter @internal/run-engine",
"cwd": "${workspaceFolder}",
"sourceMaps": true
}
]
}
4 changes: 1 addition & 3 deletions apps/coordinator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
"tinyexec": "^0.3.0"
},
"devDependencies": {
"@types/node": "^18",
"dotenv": "^16.4.2",
"esbuild": "^0.19.11",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
"tsx": "^4.7.0"
}
}
2 changes: 1 addition & 1 deletion apps/coordinator/src/checkpointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class Checkpointer {
const start = performance.now();
this.#logger.log(`checkpointAndPush() start`, { start, opts });

let interval: NodeJS.Timer | undefined;
let interval: NodeJS.Timeout | undefined;

if (opts.shouldHeartbeat) {
interval = setInterval(() => {
Expand Down
4 changes: 1 addition & 3 deletions apps/docker-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
"execa": "^8.0.1"
},
"devDependencies": {
"@types/node": "^18.19.8",
"dotenv": "^16.4.2",
"esbuild": "^0.19.11",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
"tsx": "^4.7.0"
}
}
3 changes: 1 addition & 2 deletions apps/kubernetes-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"devDependencies": {
"dotenv": "^16.4.2",
"esbuild": "^0.19.11",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
"tsx": "^4.7.0"
}
}
1 change: 0 additions & 1 deletion apps/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240512.0",
"typescript": "^5.0.4",
"wrangler": "^3.57.1"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion apps/webapp/app/consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const LIVE_ENVIRONMENT = "live";
export const DEV_ENVIRONMENT = "development";
export const CURRENT_DEPLOYMENT_LABEL = "current";
export const MAX_LIVE_PROJECTS = 1;
export const DEFAULT_MAX_CONCURRENT_RUNS = 10;
export const MAX_CONCURRENT_RUNS_LIMIT = 20;
Expand Down
3 changes: 3 additions & 0 deletions apps/webapp/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ process.on("uncaughtException", (error, origin) => {

const sqsEventConsumer = singleton("sqsEventConsumer", getSharedSqsEventConsumer);

singleton("RunEngineEventBusHandlers", registerRunEngineEventBusHandlers);

export { apiRateLimiter } from "./services/apiRateLimit.server";
export { socketIo } from "./v3/handleSocketIo.server";
export { wss } from "./v3/handleWebsockets.server";
Expand All @@ -214,6 +216,7 @@ import { eventLoopMonitor } from "./eventLoopMonitor.server";
import { env } from "./env.server";
import { logger } from "./services/logger.server";
import { Prisma } from "./db.server";
import { registerRunEngineEventBusHandlers } from "./v3/runEngineHandlers.server";

if (env.EVENT_LOOP_MONITOR_ENABLED === "1") {
eventLoopMonitor.enable();
Expand Down
33 changes: 33 additions & 0 deletions apps/webapp/app/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,33 @@ const EnvironmentSchema = z.object({
REDIS_PASSWORD: z.string().optional(),
REDIS_TLS_DISABLED: z.string().optional(),

// Valkey options (used in Run Engine 2.0+)
VALKEY_HOST: z
.string()
.nullish()
.default(process.env.REDIS_HOST ?? null),
VALKEY_READER_HOST: z
.string()
.nullish()
.default(process.env.REDIS_READER_HOST ?? null),
VALKEY_READER_PORT: z.coerce
.number()
.nullish()
.default(process.env.REDIS_READER_PORT ? parseInt(process.env.REDIS_READER_PORT) : null),
VALKEY_PORT: z.coerce
.number()
.nullish()
.default(process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT) : null),
VALKEY_USERNAME: z
.string()
.nullish()
.default(process.env.REDIS_USERNAME ?? null),
VALKEY_PASSWORD: z
.string()
.nullish()
.default(process.env.REDIS_PASSWORD ?? null),
VALKEY_TLS_DISABLED: z.string().default(process.env.REDIS_TLS_DISABLED ?? "false"),

DEFAULT_ENV_EXECUTION_CONCURRENCY_LIMIT: z.coerce.number().int().default(10),
DEFAULT_ORG_EXECUTION_CONCURRENCY_LIMIT: z.coerce.number().int().default(10),
DEFAULT_DEV_ENV_EXECUTION_ATTEMPTS: z.coerce.number().int().positive().default(1),
Expand Down Expand Up @@ -155,6 +182,7 @@ const EnvironmentSchema = z.object({
SHARED_QUEUE_CONSUMER_POOL_SIZE: z.coerce.number().int().default(10),
SHARED_QUEUE_CONSUMER_INTERVAL_MS: z.coerce.number().int().default(100),
SHARED_QUEUE_CONSUMER_NEXT_TICK_INTERVAL_MS: z.coerce.number().int().default(100),
MANAGED_WORKER_SECRET: z.string().default("managed-secret"),

// Development OTEL environment variables
DEV_OTEL_EXPORTER_OTLP_ENDPOINT: z.string().optional(),
Expand Down Expand Up @@ -245,6 +273,11 @@ const EnvironmentSchema = z.object({
MAX_BATCH_V2_TRIGGER_ITEMS: z.coerce.number().int().default(500),

REALTIME_STREAM_VERSION: z.enum(["v1", "v2"]).default("v1"),

// Run Engine 2.0
RUN_ENGINE_WORKER_COUNT: z.coerce.number().int().default(4),
RUN_ENGINE_TASKS_PER_WORKER: z.coerce.number().int().default(10),
RUN_ENGINE_WORKER_POLL_INTERVAL: z.coerce.number().int().default(100),
});

export type Environment = z.infer<typeof EnvironmentSchema>;
Expand Down
41 changes: 22 additions & 19 deletions apps/webapp/app/presenters/v3/DeploymentListPresenter.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkerDeploymentStatus } from "@trigger.dev/database";
import { WorkerDeploymentStatus, WorkerInstanceGroupType } from "@trigger.dev/database";
import { sqlDatabaseSchema, PrismaClient, prisma } from "~/db.server";
import { Organization } from "~/models/organization.server";
import { Project } from "~/models/project.server";
Expand Down Expand Up @@ -95,29 +95,31 @@ export class DeploymentListPresenter {
userName: string | null;
userDisplayName: string | null;
userAvatarUrl: string | null;
type: WorkerInstanceGroupType;
}[]
>`
SELECT
wd."id",
wd."shortCode",
wd."version",
(SELECT COUNT(*) FROM ${sqlDatabaseSchema}."BackgroundWorkerTask" WHERE "BackgroundWorkerTask"."workerId" = wd."workerId") AS "tasksCount",
wd."environmentId",
wd."status",
u."id" AS "userId",
u."name" AS "userName",
u."displayName" AS "userDisplayName",
u."avatarUrl" AS "userAvatarUrl",
SELECT
wd."id",
wd."shortCode",
wd."version",
(SELECT COUNT(*) FROM ${sqlDatabaseSchema}."BackgroundWorkerTask" WHERE "BackgroundWorkerTask"."workerId" = wd."workerId") AS "tasksCount",
wd."environmentId",
wd."status",
u."id" AS "userId",
u."name" AS "userName",
u."displayName" AS "userDisplayName",
u."avatarUrl" AS "userAvatarUrl",
wd."builtAt",
wd."deployedAt"
FROM
wd."deployedAt",
wd."type"
FROM
${sqlDatabaseSchema}."WorkerDeployment" as wd
INNER JOIN
${sqlDatabaseSchema}."User" as u ON wd."triggeredById" = u."id"
WHERE
INNER JOIN
${sqlDatabaseSchema}."User" as u ON wd."triggeredById" = u."id"
WHERE
wd."projectId" = ${project.id}
ORDER BY
string_to_array(wd."version", '.')::int[] DESC
ORDER BY
string_to_array(wd."version", '.')::int[] DESC
LIMIT ${pageSize} OFFSET ${pageSize * (page - 1)};`;

return {
Expand Down Expand Up @@ -146,6 +148,7 @@ LIMIT ${pageSize} OFFSET ${pageSize * (page - 1)};`;
isCurrent: label?.label === "current",
isDeployed: deployment.status === "DEPLOYED",
isLatest: page === 1 && index === 0,
type: deployment.type,
environment: {
id: environment.id,
type: environment.type,
Expand Down
2 changes: 2 additions & 0 deletions apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class DeploymentPresenter {
imageReference: true,
externalBuildData: true,
projectId: true,
type: true,
environment: {
select: {
id: true,
Expand Down Expand Up @@ -154,6 +155,7 @@ export class DeploymentPresenter {
organizationId: project.organizationId,
errorData: DeploymentPresenter.prepareErrorData(deployment.errorData),
isBuilt: !!deployment.builtAt,
type: deployment.type,
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/presenters/v3/RunStreamPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class RunStreamPresenter {
traceId: run.traceId,
});

let pinger: NodeJS.Timer | undefined = undefined;
let pinger: NodeJS.Timeout | undefined = undefined;

const { unsubscribe, eventEmitter } = await eventRepository.subscribeToTrace(run.traceId);

Expand Down
47 changes: 38 additions & 9 deletions apps/webapp/app/presenters/v3/SpanPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { eventRepository } from "~/v3/eventRepository.server";
import { machinePresetFromName } from "~/v3/machinePresets.server";
import { FINAL_ATTEMPT_STATUSES, isFailedRunStatus, isFinalRunStatus } from "~/v3/taskStatus";
import { BasePresenter } from "./basePresenter.server";
import { getMaxDuration } from "~/v3/utils/maxDuration";
import { getMaxDuration } from "@trigger.dev/core/v3/apps";

type Result = Awaited<ReturnType<SpanPresenter["call"]>>;
export type Span = NonNullable<NonNullable<Result>["span"]>;
Expand Down Expand Up @@ -83,6 +83,12 @@ export class SpanPresenter extends BasePresenter {
sdkVersion: true,
},
},
engine: true,
masterQueue: true,
secondaryMasterQueue: true,
error: true,
output: true,
outputType: true,
//status + duration
status: true,
startedAt: true,
Expand Down Expand Up @@ -183,13 +189,33 @@ export class SpanPresenter extends BasePresenter {
})
: null;

const finishedData =
run.engine === "V2"
? run
: isFinished
? await this._replica.taskRunAttempt.findFirst({
select: {
output: true,
outputType: true,
error: true,
},
where: {
status: { in: FINAL_ATTEMPT_STATUSES },
taskRunId: run.id,
},
orderBy: {
createdAt: "desc",
},
})
: null;

const output =
finishedAttempt === null
finishedData === null
? undefined
: finishedAttempt.outputType === "application/store"
? `/resources/packets/${run.runtimeEnvironment.id}/${finishedAttempt.output}`
: typeof finishedAttempt.output !== "undefined" && finishedAttempt.output !== null
? await prettyPrintPacket(finishedAttempt.output, finishedAttempt.outputType ?? undefined)
: finishedData.outputType === "application/store"
? `/resources/packets/${run.runtimeEnvironment.id}/${finishedData.output}`
: typeof finishedData.output !== "undefined" && finishedData.output !== null
? await prettyPrintPacket(finishedData.output, finishedData.outputType ?? undefined)
: undefined;

const payload =
Expand All @@ -200,14 +226,14 @@ export class SpanPresenter extends BasePresenter {
: undefined;

let error: TaskRunError | undefined = undefined;
if (finishedAttempt?.error) {
const result = TaskRunError.safeParse(finishedAttempt.error);
if (finishedData?.error) {
const result = TaskRunError.safeParse(finishedData.error);
if (result.success) {
error = result.data;
} else {
error = {
type: "CUSTOM_ERROR",
raw: JSON.stringify(finishedAttempt.error),
raw: JSON.stringify(finishedData.error),
};
}
}
Expand Down Expand Up @@ -320,6 +346,9 @@ export class SpanPresenter extends BasePresenter {
metadata,
maxDurationInSeconds: getMaxDuration(run.maxDurationInSeconds),
batch: run.batch ? { friendlyId: run.batch.friendlyId } : undefined,
engine: run.engine,
masterQueue: run.masterQueue,
secondaryMasterQueue: run.secondaryMasterQueue,
};
}

Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/presenters/v3/TaskListPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
import { logger } from "~/services/logger.server";
import { BasePresenter } from "./basePresenter.server";
import { TaskRunStatus } from "~/database-types";
import { CURRENT_DEPLOYMENT_LABEL } from "~/consts";
import { concurrencyTracker } from "~/v3/services/taskRunConcurrencyTracker.server";
import { CURRENT_DEPLOYMENT_LABEL } from "@trigger.dev/core/v3/apps";

export type Task = {
slug: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class TasksStreamPresenter {
projectSlug,
});

let pinger: NodeJS.Timer | undefined = undefined;
let pinger: NodeJS.Timeout | undefined = undefined;

const subscriber = await projectPubSub.subscribe(`project:${project.id}:*`);

Expand Down
Loading