project-nomad/admin/app/utils/exec_timeout.ts
Chris Sherwood e13ad44d15 fix(maps): give the region size estimate 10 minutes, and say so when it times out
The dry-run that sizes a country selection had a 60 s limit. Its runtime
scales with land area, so large selections went over it on ordinary
hardware: Canada alone takes 41 s on a fast box, US+CA+MX 61 s. The user
got a generic 500 with an empty stderr, indistinguishable from a real
failure because pmtiles buffers its output and loses it on SIGTERM.

- Raise the limit to 10 minutes.
- Detect a timeout from execFile's killed/signal/code (isExecTimeout) and
  return a 504 with a plain message instead of a 500.
- Let the country picker show the server's message inline; the call no
  longer goes through catchInternal's generic toast.

Closes #1258

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 16:36:32 -07:00

15 lines
738 B
TypeScript

/**
* Whether an `execFile` rejection means the child was killed by our `timeout`
* option rather than exiting with an error of its own.
*
* stderr cannot tell the two apart: a child that buffers its output (pmtiles
* does) loses it on SIGTERM, so a timed-out run and a run that never started can
* both come back with an empty stderr. Node marks the timeout case with
* `killed: true` plus the kill signal, and leaves `code` null (#1258).
*/
export function isExecTimeout(err: unknown): boolean {
if (!err || typeof err !== 'object') return false
const e = err as { killed?: unknown; signal?: unknown; code?: unknown }
return e.killed === true && typeof e.signal === 'string' && (e.code === null || e.code === undefined)
}