* Dispatches a background bulk update for an already-claimed job slot, mirroring * dispatchDeleteJob: trigger.dev when enabled, detached worker otherwise, releasing the * slot on a failed dispatch.
(params: {
jobId: string
tableId: string
workspaceId: string
filter: Filter
data: RowData
cutoff: Date
maxRows?: number
})
| 200 | * slot on a failed dispatch. |
| 201 | */ |
| 202 | async function dispatchUpdateJob(params: { |
| 203 | jobId: string |
| 204 | tableId: string |
| 205 | workspaceId: string |
| 206 | filter: Filter |
| 207 | data: RowData |
| 208 | cutoff: Date |
| 209 | maxRows?: number |
| 210 | }): Promise<void> { |
| 211 | const { jobId, tableId, workspaceId, filter, data, cutoff, maxRows } = params |
| 212 | if (isTriggerDevEnabled) { |
| 213 | try { |
| 214 | const [{ tableUpdateTask }, { tasks }, { resolveTriggerRegion }] = await Promise.all([ |
| 215 | import('@/background/table-update'), |
| 216 | import('@trigger.dev/sdk'), |
| 217 | import('@/lib/core/async-jobs/region'), |
| 218 | ]) |
| 219 | await tasks.trigger<typeof tableUpdateTask>( |
| 220 | 'table-update', |
| 221 | { jobId, tableId, workspaceId, filter, data, cutoff: cutoff.toISOString(), maxRows }, |
| 222 | { tags: [`tableId:${tableId}`, `jobId:${jobId}`], region: await resolveTriggerRegion() } |
| 223 | ) |
| 224 | } catch (error) { |
| 225 | await releaseJobClaim(tableId, jobId).catch(() => {}) |
| 226 | throw error |
| 227 | } |
| 228 | } else { |
| 229 | runDetached('table-update', () => |
| 230 | runTableUpdate({ jobId, tableId, workspaceId, filter, data, cutoff, maxRows }).catch( |
| 231 | async (error) => { |
| 232 | await markTableUpdateFailed(tableId, jobId, error) |
| 233 | throw error |
| 234 | } |
| 235 | ) |
| 236 | ) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Loads the live workflow state and flattens it into pickable outputs. Used |
no test coverage detected