fix(maps): wait longer than the query we ask Overpass to run

The query carries `[timeout:20]`, so the mirror is allowed twenty seconds of
work on it — and the fetch around it was aborted after twelve. A mirror under
load that would have answered at fifteen never got the chance, and the caller
saw a failed area.

That is what makes a corridor search along a long drive report half its
stretches as unsearchable: the stretches were being searched, we just hung up.
Both numbers now come from one constant, the client budget is the query's own
plus room to hand the answer back, and a test holds the relationship rather
than the two literals.
This commit is contained in:
Maurice
2026-08-29 21:05:02 +02:00
committed by Maurice
parent b339ef3f04
commit 1db55f734c
4 changed files with 37 additions and 10 deletions
+17 -7
View File
@@ -20,6 +20,8 @@ import {
buildUserAgent,
resolveOverpassEndpoints,
resolveOverpassTimeoutMs,
OVERPASS_QUERY_TIMEOUT_S,
OVERPASS_TIMEOUT_DEFAULT_MS,
stripWikiMarkup,
parseWikipediaTag,
rankCommonsCandidates,
@@ -2487,10 +2489,10 @@ describe('resolveOverpassEndpoints', () => {
// ── resolveOverpassTimeoutMs (OVERPASS_TIMEOUT_MS override, #1309) ─────────────
describe('resolveOverpassTimeoutMs', () => {
it('MAPS-104: falls back to the 12s default for unset / empty / non-numeric values', () => {
expect(resolveOverpassTimeoutMs(undefined)).toBe(12000);
expect(resolveOverpassTimeoutMs('')).toBe(12000);
expect(resolveOverpassTimeoutMs('abc')).toBe(12000);
it('MAPS-104: falls back to the default for unset / empty / non-numeric values', () => {
expect(resolveOverpassTimeoutMs(undefined)).toBe(OVERPASS_TIMEOUT_DEFAULT_MS);
expect(resolveOverpassTimeoutMs('')).toBe(OVERPASS_TIMEOUT_DEFAULT_MS);
expect(resolveOverpassTimeoutMs('abc')).toBe(OVERPASS_TIMEOUT_DEFAULT_MS);
});
it('MAPS-105: honours a positive numeric override', () => {
@@ -2498,9 +2500,17 @@ describe('resolveOverpassTimeoutMs', () => {
});
it('MAPS-106: rejects 0, negative and Infinity — a non-positive cap would 502 every search', () => {
expect(resolveOverpassTimeoutMs('0')).toBe(12000);
expect(resolveOverpassTimeoutMs('-5')).toBe(12000);
expect(resolveOverpassTimeoutMs('Infinity')).toBe(12000);
expect(resolveOverpassTimeoutMs('0')).toBe(OVERPASS_TIMEOUT_DEFAULT_MS);
expect(resolveOverpassTimeoutMs('-5')).toBe(OVERPASS_TIMEOUT_DEFAULT_MS);
expect(resolveOverpassTimeoutMs('Infinity')).toBe(OVERPASS_TIMEOUT_DEFAULT_MS);
});
it('MAPS-107: we wait longer than the query we sent is allowed to take', () => {
// The query carries `[timeout:N]`, which the mirror enforces itself. Hanging up
// before that expires aborts an answer that was still legitimately being computed —
// which is how a corridor search came to report half its stretches as unsearchable
// while every mirror was in fact working on them.
expect(OVERPASS_TIMEOUT_DEFAULT_MS).toBeGreaterThan(OVERPASS_QUERY_TIMEOUT_S * 1000);
});
});