771937adf5
## Summary Triggering a run with a very large `priority` could fail run creation outright with an opaque database error. `priority` is multiplied by 1000 and stored in a 32-bit integer column, with nothing bounding it, so a big enough value overflowed the column and the create failed. The trigger now caps the value to the highest supported priority instead of erroring, so the run is still created. ## Fix `priorityMs` (the stored `priority * 1000`) now goes through a `clampPriorityMs` helper before the write. It rounds to a whole number and clamps into the column range at both ends, so only a valid integer ever reaches the column and an out-of-range priority caps rather than failing. Single and batch triggers share the write path, so both are covered.
7 lines
207 B
TypeScript
7 lines
207 B
TypeScript
const INT4_MIN = -2_147_483_648;
|
|
const INT4_MAX = 2_147_483_647;
|
|
|
|
export function clampPriorityMs(priority: number): number {
|
|
return Math.min(Math.max(Math.round(priority * 1_000), INT4_MIN), INT4_MAX);
|
|
}
|