-
-
Notifications
You must be signed in to change notification settings - Fork 892
fix(run-engine): dequeue performance improvements and improved telemetry #2446
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
Changes from all commits
6f14c38
61a7198
3478194
3f96ae0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { | |||||
| WorkerGroupTokenService, | ||||||
| } from "~/v3/services/worker/workerGroupTokenService.server"; | ||||||
| import { API_VERSIONS, getApiVersion } from "~/api/versions"; | ||||||
| import { WORKER_HEADERS } from "@trigger.dev/core/v3/runEngineWorker"; | ||||||
|
|
||||||
|
Comment on lines
+25
to
26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainConfirm subpath export for WORKER_HEADERS. Ensure "@trigger.dev/core/v3/runEngineWorker" re-exports WORKER_HEADERS. If not, import from the consts file. Run: 🏁 Script executed: #!/bin/bash
rg -nP 'export\s+const\s+WORKER_HEADERS' packages/core/src -n -C2
rg -n '@trigger.dev/core/v3/runEngineWorker' packages/core -n || trueLength of output: 417 Replace import to use the The • File: apps/webapp/app/services/routeBuilders/apiBuilder.server.ts - import { WORKER_HEADERS } from "@trigger.dev/core/v3/runEngineWorker";
+ import { WORKER_HEADERS } from "@trigger.dev/core/v3/runEngineWorker/consts";This ensures you’re importing the actual export location and avoids a broken module resolution. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| type AnyZodSchema = z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion<any, any>; | ||||||
|
|
||||||
|
|
@@ -795,6 +796,7 @@ type WorkerLoaderHandlerFunction< | |||||
| headers: THeadersSchema extends z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion<any, any> | ||||||
| ? z.infer<THeadersSchema> | ||||||
| : undefined; | ||||||
| runnerId?: string; | ||||||
| }) => Promise<Response>; | ||||||
|
|
||||||
| export function createLoaderWorkerApiRoute< | ||||||
|
|
@@ -858,12 +860,15 @@ export function createLoaderWorkerApiRoute< | |||||
| parsedHeaders = headers.data; | ||||||
| } | ||||||
|
|
||||||
| const runnerId = request.headers.get(WORKER_HEADERS.RUNNER_ID) ?? undefined; | ||||||
|
|
||||||
| const result = await handler({ | ||||||
| params: parsedParams, | ||||||
| searchParams: parsedSearchParams, | ||||||
| authenticatedWorker: authenticationResult, | ||||||
| request, | ||||||
| headers: parsedHeaders, | ||||||
| runnerId, | ||||||
| }); | ||||||
| return result; | ||||||
| } catch (error) { | ||||||
|
|
@@ -924,6 +929,7 @@ type WorkerActionHandlerFunction< | |||||
| body: TBodySchema extends z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion<any, any> | ||||||
| ? z.infer<TBodySchema> | ||||||
| : undefined; | ||||||
| runnerId?: string; | ||||||
| }) => Promise<Response>; | ||||||
|
|
||||||
| export function createActionWorkerApiRoute< | ||||||
|
|
@@ -1021,13 +1027,16 @@ export function createActionWorkerApiRoute< | |||||
| parsedBody = parsed.data; | ||||||
| } | ||||||
|
|
||||||
| const runnerId = request.headers.get(WORKER_HEADERS.RUNNER_ID) ?? undefined; | ||||||
|
|
||||||
| const result = await handler({ | ||||||
| params: parsedParams, | ||||||
| searchParams: parsedSearchParams, | ||||||
| authenticatedWorker: authenticationResult, | ||||||
| request, | ||||||
| body: parsedBody, | ||||||
| headers: parsedHeaders, | ||||||
| runnerId, | ||||||
| }); | ||||||
| return result; | ||||||
| } catch (error) { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,6 +67,9 @@ function createRunEngine() { | |||||||||||||||||
| dequeueBlockingTimeoutSeconds: env.RUN_ENGINE_DEQUEUE_BLOCKING_TIMEOUT_SECONDS, | ||||||||||||||||||
| masterQueueConsumersIntervalMs: env.RUN_ENGINE_MASTER_QUEUE_CONSUMERS_INTERVAL_MS, | ||||||||||||||||||
| masterQueueConsumersDisabled: env.RUN_ENGINE_WORKER_ENABLED === "0", | ||||||||||||||||||
| masterQueueCooloffPeriodMs: env.RUN_ENGINE_MASTER_QUEUE_COOLOFF_PERIOD_MS, | ||||||||||||||||||
| masterQueueCooloffCountThreshold: env.RUN_ENGINE_MASTER_QUEUE_COOLOFF_COUNT_THRESHOLD, | ||||||||||||||||||
| masterQueueConsumerDequeueCount: env.RUN_ENGINE_MASTER_QUEUE_CONSUMER_DEQUEUE_COUNT, | ||||||||||||||||||
| concurrencySweeper: { | ||||||||||||||||||
|
Comment on lines
+70
to
73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Defensive clamping of queue controls at runtime Add guards so a bad env can’t zero-out dequeues or set a 0ms cooloff. - masterQueueCooloffPeriodMs: env.RUN_ENGINE_MASTER_QUEUE_COOLOFF_PERIOD_MS,
- masterQueueCooloffCountThreshold: env.RUN_ENGINE_MASTER_QUEUE_COOLOFF_COUNT_THRESHOLD,
- masterQueueConsumerDequeueCount: env.RUN_ENGINE_MASTER_QUEUE_CONSUMER_DEQUEUE_COUNT,
+ masterQueueCooloffPeriodMs: Math.max(100, env.RUN_ENGINE_MASTER_QUEUE_COOLOFF_PERIOD_MS),
+ masterQueueCooloffCountThreshold: Math.max(1, env.RUN_ENGINE_MASTER_QUEUE_COOLOFF_COUNT_THRESHOLD),
+ masterQueueConsumerDequeueCount: Math.max(1, env.RUN_ENGINE_MASTER_QUEUE_CONSUMER_DEQUEUE_COUNT),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| scanSchedule: env.RUN_ENGINE_CONCURRENCY_SWEEPER_SCAN_SCHEDULE, | ||||||||||||||||||
| processMarkedSchedule: env.RUN_ENGINE_CONCURRENCY_SWEEPER_PROCESS_MARKED_SCHEDULE, | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.