* Dispatches a background import for an already-claimed job slot, mirroring the * import-async routes: trigger.dev when enabled (survives deploys, retries), * detached in-process worker otherwise. A failed dispatch releases the claim so * a ghost `running` job can't hold the table's one-write-job
(payload: TableImportPayload)
| 132 | * a ghost `running` job can't hold the table's one-write-job slot. |
| 133 | */ |
| 134 | async function dispatchImportJob(payload: TableImportPayload): Promise<void> { |
| 135 | if (isTriggerDevEnabled) { |
| 136 | try { |
| 137 | const [{ tableImportTask }, { tasks }, { resolveTriggerRegion }] = await Promise.all([ |
| 138 | import('@/background/table-import'), |
| 139 | import('@trigger.dev/sdk'), |
| 140 | import('@/lib/core/async-jobs/region'), |
| 141 | ]) |
| 142 | await tasks.trigger<typeof tableImportTask>('table-import', payload, { |
| 143 | tags: [`tableId:${payload.tableId}`, `jobId:${payload.importId}`], |
| 144 | region: await resolveTriggerRegion(), |
| 145 | }) |
| 146 | } catch (error) { |
| 147 | await releaseJobClaim(payload.tableId, payload.importId).catch(() => {}) |
| 148 | throw error |
| 149 | } |
| 150 | } else { |
| 151 | runDetached('table-import', () => runTableImport(payload)) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Dispatches a background filter-delete for an already-claimed job slot, |
no test coverage detected