-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(core): add default region config to tasks and scheduled tasks #3088
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "BackgroundWorkerTask" ADD COLUMN "region" TEXT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -559,6 +559,7 @@ model BackgroundWorkerTask { | |
| queueConfig Json? | ||
| retryConfig Json? | ||
| machineConfig Json? | ||
| regionConfig String? | ||
|
Comment on lines
559
to
+562
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.
All adjacent Consider using 🗄️ Proposed schema alternative- regionConfig String?
+ regionConfig Json?And correspondingly in - regionConfig: task.region,
+ regionConfig: task.region ?? null,(No other change needed since Prisma will accept a 🤖 Prompt for AI Agents |
||
|
|
||
| queueId String? | ||
| queue TaskQueue? @relation(fields: [queueId], references: [id], onDelete: SetNull, onUpdate: Cascade) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,13 @@ export type TriggerConfig = { | |
| */ | ||
| machine?: MachinePresetName; | ||
|
|
||
| /** | ||
| * The default region to run your tasks in. You can override this on a per-task basis or at trigger time. | ||
| * | ||
| * Check the Regions page in the dashboard for regions that are available to you. | ||
| */ | ||
| region?: string; | ||
|
Comment on lines
+144
to
+149
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. 🧩 Analysis chain🏁 Script executed: # Check if .changeset directory exists and list its contents
if [ -d ".changeset" ]; then
echo "=== Changeset files ==="
find .changeset -type f -name "*.md" | grep -v "CHANGELOG" | head -20
else
echo "No .changeset directory found"
fiRepository: triggerdotdev/trigger.dev Length of output: 480 🏁 Script executed: # Check the structure of packages/core to understand the scope
echo "=== Checking packages/core directory ==="
ls -la packages/core/src/v3/ 2>/dev/null || echo "v3 directory not found"Repository: triggerdotdev/trigger.dev Length of output: 4430 🏁 Script executed: # Search for any changeset files that mention core, trigger-sdk, or version changes
echo "=== Searching changeset content ==="
if [ -d ".changeset" ]; then
find .changeset -type f -name "*.md" ! -name "CHANGELOG*" -exec grep -l "core\|sdk\|region\|config" {} \;
fiRepository: triggerdotdev/trigger.dev Length of output: 366 🏁 Script executed: # Check the content of changesets that matched the search
echo "=== Changeset contents ==="
for file in .changeset/add-debounce-maxdelay.md .changeset/afraid-gorillas-jump.md .changeset/consistent-stream-targets.md .changeset/export-start-attempt-hook-type.md .changeset/tricky-suits-design.md .changeset/vendor-superjson-esm-fix.md .changeset/vercel-integration.md; do
if [ -f "$file" ]; then
echo ""
echo "--- File: $file ---"
cat "$file"
fi
doneRepository: triggerdotdev/trigger.dev Length of output: 3210 🏁 Script executed: # Also check if there are any other changesets we might have missed
echo "=== All changeset files (non-README) ==="
find .changeset -type f -name "*.md" ! -name "README.md" -exec basename {} \;Repository: triggerdotdev/trigger.dev Length of output: 366 🏁 Script executed: # Check the remaining changesets we haven't seen yet
for file in .changeset/calm-hooks-wait.md .changeset/fix-dead-process-execute-hang.md .changeset/mcp-wait-timeout.md; do
if [ -f "$file" ]; then
echo ""
echo "--- File: $file ---"
cat "$file"
fi
doneRepository: triggerdotdev/trigger.dev Length of output: 750 🏁 Script executed: # Now let's check what the actual change is in config.ts to match it with a changeset
echo "=== Checking config.ts file around lines 144-149 ==="
sed -n '140,155p' packages/core/src/v3/config.tsRepository: triggerdotdev/trigger.dev Length of output: 661 Add a changeset for the The 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Set the log level for the logger. Defaults to "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,6 +186,7 @@ const taskMetadata = { | |
| queue: QueueManifest.extend({ name: z.string().optional() }).optional(), | ||
| retry: RetryOptions.optional(), | ||
| machine: MachineConfig.optional(), | ||
| region: z.string().optional(), | ||
|
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for changesets in the .changeset directory
ls -la .changeset/ 2>/dev/null | head -20
# List all markdown files in .changeset
fd -e md . .changeset/ 2>/dev/nullRepository: triggerdotdev/trigger.dev Length of output: 1449 🏁 Script executed: #!/bin/bash
# Search for changesets mentioning 'core' package
find .changeset -type f -name "*.md" 2>/dev/null -exec grep -l "@trigger.dev/core\|core" {} \;Repository: triggerdotdev/trigger.dev Length of output: 210 🏁 Script executed: #!/bin/bash
# Examine the file to understand the scope of changes
wc -l packages/core/src/v3/schemas/schemas.tsRepository: triggerdotdev/trigger.dev Length of output: 112 🏁 Script executed: #!/bin/bash
# Check the content of changesets that mention core
for file in .changeset/add-debounce-maxdelay.md .changeset/tricky-suits-design.md .changeset/vendor-superjson-esm-fix.md .changeset/vercel-integration.md; do
echo "=== $file ==="
cat "$file"
echo ""
doneRepository: triggerdotdev/trigger.dev Length of output: 1419 🏁 Script executed: #!/bin/bash
# Read the schemas.ts file to see the changes
cat -n packages/core/src/v3/schemas/schemas.tsRepository: triggerdotdev/trigger.dev Length of output: 11516 🏁 Script executed: #!/bin/bash
# Search for any changeset mentioning "region"
find .changeset -type f -name "*.md" -exec grep -l "region" {} \;Repository: triggerdotdev/trigger.dev Length of output: 51 🏁 Script executed: #!/bin/bash
# Search for TaskResource and CommonTaskOptions in the schemas file and related files
grep -n "TaskResource\|CommonTaskOptions" packages/core/src/v3/schemas/schemas.ts
# Also search in other schema files
fd -e ts . packages/core/src/v3/ --exec grep -l "TaskResource\|CommonTaskOptions" {} \;Repository: triggerdotdev/trigger.dev Length of output: 187 🏁 Script executed: #!/bin/bash
# Search the entire codebase for TaskResource and CommonTaskOptions
rg "TaskResource|CommonTaskOptions" packages/core --type ts -A 2Repository: triggerdotdev/trigger.dev Length of output: 2472 🏁 Script executed: #!/bin/bash
# Examine TaskResource in resources.ts
cat -n packages/core/src/v3/schemas/resources.ts | head -50Repository: triggerdotdev/trigger.dev Length of output: 2124 🏁 Script executed: #!/bin/bash
# Examine CommonTaskOptions in tasks.ts
wc -l packages/core/src/v3/types/tasks.ts
cat -n packages/core/src/v3/types/tasks.ts | head -100Repository: triggerdotdev/trigger.dev Length of output: 3848 🏁 Script executed: #!/bin/bash
# Find CommonTaskOptions definition in tasks.ts
grep -n "type CommonTaskOptions" packages/core/src/v3/types/tasks.ts -A 30Repository: triggerdotdev/trigger.dev Length of output: 1032 🏁 Script executed: #!/bin/bash
# Get more lines of CommonTaskOptions to see if region is defined
grep -n "type CommonTaskOptions" packages/core/src/v3/types/tasks.ts -A 100 | head -120Repository: triggerdotdev/trigger.dev Length of output: 2773 🏁 Script executed: #!/bin/bash
# Search for "region" specifically in the CommonTaskOptions definition
sed -n '172,400p' packages/core/src/v3/types/tasks.ts | grep -n "region"Repository: triggerdotdev/trigger.dev Length of output: 321 🏁 Script executed: #!/bin/bash
# Get the full CommonTaskOptions type definition
sed -n '172,350p' packages/core/src/v3/types/tasks.tsRepository: triggerdotdev/trigger.dev Length of output: 4952 Add changeset for The 🤖 Prompt for AI Agents |
||
| triggerSource: z.string().optional(), | ||
| schedule: ScheduleMetadata.optional(), | ||
| maxDuration: z.number().optional(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,6 +277,25 @@ type CommonTaskOptions< | |
| */ | ||
| maxDuration?: number; | ||
|
|
||
| /** | ||
| * The default region to run this task in. This can be overridden at trigger time via `options.region`. | ||
| * | ||
| * Check the Regions page in the dashboard for regions that are available to you. | ||
| * | ||
| * @example | ||
| * | ||
| * ```ts | ||
| * export const heavyTask = task({ | ||
| * id: "heavy-task", | ||
| * region: "us-east-1", | ||
| * run: async ({ payload, ctx }) => { | ||
| * // ... | ||
| * }, | ||
| * }); | ||
| * ``` | ||
| */ | ||
| region?: string; | ||
|
Comment on lines
+280
to
+297
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. Partial implementation vs. linked issue spec. Issue If this is a deliberate phase-1 simplification, please add an inline comment or a TODO to document the intent. 🤖 Prompt for AI Agents
Contributor
Author
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. @ericallam I have renamed this to region instead of regionConfig, do you like to see fallback option or keep this as plain string? currently it is going to throw error that region does not exist.
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.
|
||
|
|
||
| /** This gets called when a task is triggered. It's where you put the code you want to execute. | ||
| * | ||
| * @param payload - The payload that is passed to your task when it's triggered. This must be JSON serializable. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 14904
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 2489
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 5998
getQueueNamereturns an unsanitized queue name whileresolveQueuePropertiessanitizes—creating inconsistent behavior for the same interface.Both methods extract queue info via
_getQueueInfo, butresolveQueuePropertiesappliessanitizeQueueName(lines 154–161) whilegetQueueNamereturns the raw result directly (lines 170–173). Since_getQueueInfocan return user-provided or raw database queue names without sanitization, callers ofgetQueueNamemay receive unsanitized names containing spaces or special characters, whileresolveQueuePropertiescallers receive sanitized names—causing mismatches with stored queues.🔧 Suggested fix — apply the same sanitization as `resolveQueueProperties`
async getQueueName(request: TriggerTaskRequest): Promise<string> { const { queueName } = await this._getQueueInfo(request); - return queueName; + const sanitized = sanitizeQueueName(queueName); + return sanitized || sanitizeQueueName(`task/${request.taskId}`) || `task/${request.taskId}`; }📝 Committable suggestion
🤖 Prompt for AI Agents