project-nomad/admin/tests/unit/exec_timeout.spec.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

24 lines
873 B
TypeScript

import * as assert from 'node:assert/strict'
import { test } from 'node:test'
import { isExecTimeout } from '../../app/utils/exec_timeout.js'
/** Regression: #1258. A dry-run killed by the timeout surfaced as a generic 500. */
test('a child killed by the timeout option is a timeout', () => {
assert.equal(isExecTimeout({ killed: true, signal: 'SIGTERM', code: null, stderr: '' }), true)
})
test('a child that exited non-zero is not a timeout, even with empty stderr', () => {
assert.equal(isExecTimeout({ killed: false, signal: null, code: 1, stderr: '' }), false)
})
test('a binary that could not be spawned is not a timeout', () => {
assert.equal(isExecTimeout({ code: 'ENOENT', errno: -2 }), false)
})
test('non-objects are not timeouts', () => {
for (const value of [undefined, null, 'timeout', 42]) {
assert.equal(isExecTimeout(value), false)
}
})