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 434 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
434 commits
Select commit Hold shift + click to select a range
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
3d4068a
RunEngine 2.0 batch trigger support (#1581)
matt-aitken Jan 2, 2025
0642c9c
More changes to blocking to support continuing after idempotent compl…
matt-aitken Jan 3, 2025
fdf0bf6
Fix for the wrong type when blocking a run
matt-aitken Jan 3, 2025
d6e8743
remove @map
nicktrn Jan 2, 2025
9d24fc1
optimise worker auth query
nicktrn Jan 2, 2025
446a94f
add engine version header to core api client requests
nicktrn Jan 2, 2025
ca82d75
remove unique constraint for default group id
nicktrn Jan 3, 2025
3c67350
consolidate migrations
nicktrn Jan 3, 2025
f961a75
the first managed worker becomes the global default
nicktrn Jan 3, 2025
3e2687e
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Jan 3, 2025
45a829e
Debug events off by default, added an admin toggle to show them
matt-aitken Jan 3, 2025
a254602
worker group name can't be an empty string
nicktrn Jan 5, 2025
bc38276
add exec helper to core
nicktrn Jan 7, 2025
1d6fb48
move machine resources to core
nicktrn Jan 7, 2025
a76ef98
add pre-dequeue callback to determine max resources
nicktrn Jan 7, 2025
5cf7c52
optionally skip dequeue
nicktrn Jan 7, 2025
994ac3e
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Jan 8, 2025
70abb63
bump worker package
nicktrn Jan 8, 2025
f319d3a
move worker to core
nicktrn Jan 8, 2025
74dd91f
fix ReadableStream type error
nicktrn Jan 8, 2025
8704e77
Merge remote-tracking branch 'origin/main' into run-engine-2
nicktrn Jan 8, 2025
4f8ce0b
fix another type issue
nicktrn Jan 8, 2025
b8cb8dc
update a few more tsconfigs
nicktrn Jan 8, 2025
b12b617
add metadata changes introduced in #1563
nicktrn Jan 8, 2025
c8b835a
Run Engine 2.0 trigger idempotency (#1613)
matt-aitken Jan 15, 2025
e742e8b
Merge remote-tracking branch 'origin/main' into run-engine-2
matt-aitken Jan 17, 2025
e942c04
Latest lockfile
matt-aitken Jan 17, 2025
68813bb
Trigger with a machine (old run engine)
matt-aitken Jan 17, 2025
a37b528
RE2, allow setting machine when triggering
matt-aitken Jan 17, 2025
46e0698
Fix for new glob patterns
matt-aitken Jan 17, 2025
41cfaa4
add max run count to dequeue from version route
nicktrn Jan 12, 2025
6ff1893
add worker instance name env var and header
nicktrn Jan 12, 2025
35ab2bd
queue consumer pre skip callback
nicktrn Jan 12, 2025
05c0ee9
poll for more runs after final execution errors
nicktrn Jan 14, 2025
6b8bd66
fix dequeue search param schema
nicktrn Jan 14, 2025
8aa07e7
add shortcut to debug switch
nicktrn Jan 16, 2025
9da8029
expose run engine timeouts as env vars
nicktrn Jan 16, 2025
5f95a7b
make warm start durations configurable
nicktrn Jan 16, 2025
54d297f
add optional status to json reply helper
nicktrn Jan 16, 2025
7733a72
fix preSkip hook, add debug logs
nicktrn Jan 16, 2025
e936cea
BLOCKED_BY_WAITPOINTS -> SUSPENDED
nicktrn Jan 16, 2025
39fa134
exit controller when run suspended
nicktrn Jan 16, 2025
5002ad8
check if already replied before http reply
nicktrn Jan 16, 2025
3e21ad5
run controller will wait for next run after the current one is suspended
nicktrn Jan 17, 2025
acdb65a
cancel run button shortcut
nicktrn Jan 22, 2025
b9b1679
minimal event repository environment type
nicktrn Jan 22, 2025
b77a8d3
fix update metadata call
nicktrn Jan 22, 2025
87bbeac
run suspension and misc fixes wip
nicktrn Jan 22, 2025
d88310a
change debug shortcut to shift + D
nicktrn Jan 22, 2025
76d4cb0
Started work on the Dev supervisor
matt-aitken Jan 27, 2025
40223c0
Formatting
matt-aitken Jan 27, 2025
45d1b12
Fix for bad imports
matt-aitken Jan 27, 2025
57be5d0
Before rebuilding SSE
matt-aitken Jan 29, 2025
88b30d7
Presence updating from the CLI working via SSE
matt-aitken Jan 29, 2025
9bc223a
add worker notification debug logs
nicktrn Jan 23, 2025
06db938
send run:stop when exiting run phase
nicktrn Jan 23, 2025
dbfa1bd
skip current snapshot poll on worker notification
nicktrn Jan 27, 2025
de05bda
add more logs and route to submit run debug logs
nicktrn Jan 27, 2025
e1ad2c1
add worker and runner ids to snapshots
nicktrn Jan 28, 2025
426259a
improve run notification debug logs
nicktrn Jan 29, 2025
f85d8ee
add workload debug log route
nicktrn Jan 29, 2025
4744ba0
misc run controller fixes and refactor
nicktrn Jan 29, 2025
bd7479b
prevent parallel execution of critical functions
nicktrn Jan 30, 2025
d89d5f1
update bun to 1.2.1
nicktrn Jan 30, 2025
a8a3b20
WIP with dev dequeuing
matt-aitken Jan 30, 2025
117bc4d
Method to convert friendlyIds to non-friendly, do nothing with actual…
matt-aitken Jan 31, 2025
66d392c
Set the engine on BackgroundWorker, lazily upgrade projects to engine V2
matt-aitken Jan 31, 2025
8317e80
Runs with ttls were getting immediately expired… oops.
matt-aitken Jan 31, 2025
da0d4a0
Pass the Waiting for deploy reason through, so we have it on the exec…
matt-aitken Jan 31, 2025
b7e3801
Fixed the logic for getting the right background worker for a run
matt-aitken Jan 31, 2025
8144140
Use the correct ID when dequeuing…
matt-aitken Jan 31, 2025
323cfce
determineEngineVersion is now fully functional
matt-aitken Jan 31, 2025
adeb113
Rate limiter ignores the dev endpoints
matt-aitken Jan 31, 2025
881986c
Retrieving a batch gives you the runIds
matt-aitken Jan 31, 2025
19693fa
Set a unique version for the RE2 BatchTaskRun
matt-aitken Jan 31, 2025
84c590b
add provisional changeset
nicktrn Feb 3, 2025
8da1e6b
The start of dev run execution is working
matt-aitken Feb 3, 2025
864fa1b
First dev run working
matt-aitken Feb 3, 2025
2580b3a
Moved the dev run controller closer to what Nick did with the managed…
matt-aitken Feb 4, 2025
eee6a4d
export exec output type
nicktrn Feb 4, 2025
837ba73
Heartbeat fix: don’t heartbeat if _isHeartbeating == false
matt-aitken Feb 4, 2025
d995cf0
Dev runs get notifications, some dev bug fixes
matt-aitken Feb 4, 2025
6a5f228
Improved logging or dequeuing
matt-aitken Feb 4, 2025
684b72b
We need to dequeue runs from the latest version too, for triggerAndWait
matt-aitken Feb 4, 2025
f016857
Ported Eric’s validateWorkerManifest with nicer errors
matt-aitken Feb 4, 2025
ef970cd
When flattening an idempotency key if part is undefined, return undef…
matt-aitken Feb 4, 2025
b7f4959
Dev logging fixes
matt-aitken Feb 5, 2025
5cb706c
Remove sigterm listener
matt-aitken Feb 5, 2025
b19498c
Deprecating workers. Don’t specify a BackgroundWorker when dequeuing …
matt-aitken Feb 5, 2025
1d882d7
Deleted some old files. Renamed “managed” to “deploy”
matt-aitken Feb 5, 2025
cb24953
When a build finishes, always copy the build dir (otherwise the first…
matt-aitken Feb 5, 2025
87e8e89
Dev master queues should work differently
matt-aitken Feb 5, 2025
a0216b9
Deleting old workers
matt-aitken Feb 5, 2025
4e27563
Added debounce function to core
matt-aitken Feb 6, 2025
a2f36b6
Improvement to canceling
matt-aitken Feb 6, 2025
6bfc246
WIP on debounce canceling on socket disconnection
matt-aitken Feb 6, 2025
d8e4c43
Added environment data to execution snapshots
matt-aitken Feb 7, 2025
6088c27
Dev runs that have stalled get “Canceled” with a reason explaining why
matt-aitken Feb 7, 2025
8ec03c5
Show CLI messaged when a connection to the platform is lost/restored
matt-aitken Feb 7, 2025
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
10 changes: 10 additions & 0 deletions .changeset/breezy-turtles-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@trigger.dev/react-hooks": patch
"@trigger.dev/sdk": patch
"trigger.dev": patch
"@trigger.dev/build": patch
"@trigger.dev/core": patch
"@trigger.dev/rsc": patch
---

Run Engine 2.0 (alpha)
2 changes: 1 addition & 1 deletion .configs/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2022",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"lib": ["ES2022", "DOM", "DOM.Iterable", "DOM.AsyncIterable"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"moduleDetection": "force",
Expand Down
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 @@
node-version: 20.11.1
cache: "pnpm"

# ..to avoid rate limits when pulling images
- name: 🐳 Login to DockerHub
uses: docker/login-action@v3

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action '🧪 Unit Tests' step
Uses Step
uses 'docker/login-action' with ref 'v3', not a pinned commit hash
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/coordinator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"include": ["./src/**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"target": "es2016",
"target": "es2018",
"module": "commonjs",
"esModuleInterop": true,
"resolveJsonModule": true,
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"
}
}
2 changes: 1 addition & 1 deletion apps/kubernetes-provider/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2016",
"target": "es2018",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down
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
49 changes: 49 additions & 0 deletions apps/webapp/app/assets/icons/TaskCachedIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export function TaskCachedIcon({ className }: { className?: string }) {
return (
<svg
className={className}
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#clip0_15584_76102)">
<path
d="M0.5 3.5L0.5 2.5C0.5 1.39543 1.39543 0.5 2.5 0.5H3.5"
stroke="#3B82F6"
strokeLinecap="square"
strokeLinejoin="round"
/>
<path
d="M15.5 12.5L15.5 13.5C15.5 14.6046 14.6046 15.5 13.5 15.5L12.5 15.5"
stroke="#3B82F6"
strokeLinecap="square"
strokeLinejoin="round"
/>
<path
d="M12.5 0.5L13.5 0.5C14.6046 0.5 15.5 1.39543 15.5 2.5L15.5 3.5"
stroke="#3B82F6"
strokeLinecap="square"
strokeLinejoin="round"
/>
<path
d="M3.5 15.5L2.5 15.5C1.39543 15.5 0.5 14.6046 0.5 13.5L0.5 12.5"
stroke="#3B82F6"
strokeLinecap="square"
strokeLinejoin="round"
/>
<path d="M11.1799 4.19V5.598H8.8479V12H7.1649V5.598H4.8219V4.19H11.1799Z" fill="#3B82F6" />
<line x1="6" y1="15.5" x2="10" y2="15.5" stroke="#3B82F6" />
<line x1="6" y1="0.5" x2="10" y2="0.5" stroke="#3B82F6" />
<line x1="15.5" y1="6" x2="15.5" y2="10" stroke="#3B82F6" />
<line x1="0.5" y1="6" x2="0.5" y2="10" stroke="#3B82F6" />
</g>
<defs>
<clipPath id="clip0_15584_76102">
<rect width="16" height="16" fill="white" />
</clipPath>
</defs>
</svg>
);
}
23 changes: 22 additions & 1 deletion apps/webapp/app/components/primitives/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as React from "react";
import * as SwitchPrimitives from "@radix-ui/react-switch";
import { cn } from "~/utils/cn";
import { ShortcutDefinition, useShortcutKeys } from "~/hooks/useShortcutKeys";

const variations = {
large: {
Expand All @@ -23,14 +24,34 @@ const variations = {
type SwitchProps = React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> & {
label?: React.ReactNode;
variant: keyof typeof variations;
shortcut?: ShortcutDefinition;
};

export const Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.Root>, SwitchProps>(
({ className, variant, label, ...props }, ref) => {
const innerRef = React.useRef<HTMLButtonElement>(null);
React.useImperativeHandle(ref, () => innerRef.current as HTMLButtonElement);

const { container, root, thumb, text } = variations[variant];

if (props.shortcut) {
useShortcutKeys({
shortcut: props.shortcut,
action: () => {
if (innerRef.current) {
innerRef.current.click();
}
},
disabled: props.disabled,
});
}
Comment on lines +37 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Move shortcut action outside render function and avoid conditional hook.

The current implementation has two issues:

  1. The shortcut action is defined inside the render function, which could cause unnecessary re-renders
  2. The useShortcutKeys hook is called conditionally, which violates React hooks rules

Apply this diff to fix both issues:

+  const handleShortcutAction = React.useCallback(() => {
+    if (innerRef.current) {
+      innerRef.current.click();
+    }
+  }, []);
+
+  useShortcutKeys({
+    shortcut: props.shortcut,
+    action: handleShortcutAction,
+    disabled: props.disabled,
+    enabled: !!props.shortcut,
+  });
-    if (props.shortcut) {
-      useShortcutKeys({
-        shortcut: props.shortcut,
-        action: () => {
-          if (innerRef.current) {
-            innerRef.current.click();
-          }
-        },
-        disabled: props.disabled,
-      });
-    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (props.shortcut) {
useShortcutKeys({
shortcut: props.shortcut,
action: () => {
if (innerRef.current) {
innerRef.current.click();
}
},
disabled: props.disabled,
});
}
const handleShortcutAction = React.useCallback(() => {
if (innerRef.current) {
innerRef.current.click();
}
}, []);
useShortcutKeys({
shortcut: props.shortcut,
action: handleShortcutAction,
disabled: props.disabled,
enabled: !!props.shortcut,
});


return (
<SwitchPrimitives.Root className={cn("group", container, className)} {...props} ref={ref}>
<SwitchPrimitives.Root
className={cn("group", container, className)}
{...props}
ref={innerRef}
>
{label ? (
<label className={cn("whitespace-nowrap", text)}>
{typeof label === "string" ? <span>{label}</span> : label}
Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/components/runs/v3/BatchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ function BatchIdDropdown({
if (batchId) {
if (!batchId.startsWith("batch_")) {
error = "Batch IDs start with 'batch_'";
} else if (batchId.length !== 27) {
error = "Batch IDs are 27 characters long";
} else if (batchId.length !== 27 && batchId.length !== 31) {
error = "Batch IDs are 27/32 characters long";
Comment on lines +362 to +363
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

⚠️ Potential issue

🧩 Analysis chain

Inconsistency in batch ID length validation.

The error message states "27/32 characters" but the validation checks for "27/31 characters". This mismatch could confuse users.

Apply this diff to fix the error message:

-      error = "Batch IDs are 27/32 characters long";
+      error = "Batch IDs are 27/31 characters long";

Additionally, there's an inconsistency with the validation in RunFilters.tsx where batch IDs are still required to be exactly 27 characters long.

Run the following script to verify the batch ID validation across the codebase:


🏁 Script executed:

#!/bin/bash
# Description: Search for batch ID validation logic to ensure consistency.

# Test: Search for batch ID length validation. Expect: Only occurrences of the new validation.
rg -A 5 'batch.*length.*27'

Length of output: 896


Batch ID Validation Inconsistency Found

  • In apps/webapp/app/components/runs/v3/BatchFilters.tsx, the condition checks for batch IDs with lengths 27 or 31, but the error message incorrectly indicates "27/32 characters long." The suggested fix is to update it to "27/31 characters long."
  • Additionally, in apps/webapp/app/components/runs/v3/RunFilters.tsx, the validation is stricter—requiring exactly 27 characters—which introduces an inconsistency between the two components.

}
}

Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/components/runs/v3/RunFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ function RunIdDropdown({
if (runId) {
if (!runId.startsWith("run_")) {
error = "Run IDs start with 'run_'";
} else if (runId.length !== 25) {
error = "Run IDs are 25 characters long";
} else if (runId.length !== 25 && runId.length !== 29) {
error = "Run IDs are 25/30 characters long";
Comment on lines +766 to +767
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency in run ID length error message.

The error message states "25/30 characters" but the validation checks for "25/29 characters". This mismatch could confuse users.

Apply this diff to fix the error message:

-      error = "Run IDs are 25/30 characters long";
+      error = "Run IDs are 25/29 characters long";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else if (runId.length !== 25 && runId.length !== 29) {
error = "Run IDs are 25/30 characters long";
} else if (runId.length !== 25 && runId.length !== 29) {
error = "Run IDs are 25/29 characters long";

}
}

Expand Down
3 changes: 3 additions & 0 deletions apps/webapp/app/components/runs/v3/RunIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "@heroicons/react/20/solid";
import { AttemptIcon } from "~/assets/icons/AttemptIcon";
import { TaskIcon } from "~/assets/icons/TaskIcon";
import { TaskCachedIcon } from "~/assets/icons/TaskCachedIcon";
import { NamedIcon } from "~/components/primitives/NamedIcon";
import { cn } from "~/utils/cn";

Expand Down Expand Up @@ -41,6 +42,8 @@ export function RunIcon({ name, className, spanName }: TaskIconProps) {
switch (name) {
case "task":
return <TaskIcon className={cn(className, "text-blue-500")} />;
case "task-cached":
return <TaskCachedIcon className={cn(className, "text-blue-500")} />;
case "scheduled":
return <ClockIcon className={cn(className, "text-sun-500")} />;
case "attempt":
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
49 changes: 49 additions & 0 deletions apps/webapp/app/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,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 @@ -162,6 +189,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 @@ -261,6 +289,27 @@ const EnvironmentSchema = z.object({
BATCH_METADATA_OPERATIONS_FLUSH_INTERVAL_MS: z.coerce.number().int().default(1000),
BATCH_METADATA_OPERATIONS_FLUSH_ENABLED: z.string().default("1"),
BATCH_METADATA_OPERATIONS_FLUSH_LOGGING_ENABLED: z.string().default("1"),

// 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),
RUN_ENGINE_TIMEOUT_PENDING_EXECUTING: z.coerce.number().int().default(60_000),
RUN_ENGINE_TIMEOUT_PENDING_CANCEL: z.coerce.number().int().default(60_000),
RUN_ENGINE_TIMEOUT_EXECUTING: z.coerce.number().int().default(60_000),
RUN_ENGINE_TIMEOUT_EXECUTING_WITH_WAITPOINTS: z.coerce.number().int().default(60_000),
RUN_ENGINE_DEBUG_WORKER_NOTIFICATIONS: z.coerce.boolean().default(false),

/** How long should the presence ttl last */
DEV_PRESENCE_TTL_MS: z.coerce.number().int().default(30_000),
DEV_PRESENCE_POLL_INTERVAL_MS: z.coerce.number().int().default(5_000),
DEV_PRESENCE_RECONNECT_THRESHOLD_MS: z.coerce.number().int().default(2_000),
/** How many ms to wait until dequeuing again, if there was a run last time */
DEV_DEQUEUE_INTERVAL_WITH_RUN: z.coerce.number().int().default(250),
/** How many ms to wait until dequeuing again, if there was no run last time */
DEV_DEQUEUE_INTERVAL_WITHOUT_RUN: z.coerce.number().int().default(1_000),
/** The max number of runs per API call that we'll dequeue in DEV */
DEV_DEQUEUE_MAX_RUNS_PER_PULL: z.coerce.number().int().default(10),
});

export type Environment = z.infer<typeof EnvironmentSchema>;
Expand Down
Loading