mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(terrain): keep cold height requests within the browser deadline (#348)
Use 64-point browser and upstream terrain batches to reduce cold-cache timeouts. Preserve successful chunk results, distinguish absent readings from malformed responses, and reject fabricated zero heights. Original terrain resilience contribution by ItzDESTAQ, with browser batching, validation and regression follow-up by Sameh Khamis. Validated with unit/build/format/boundary checks, 108 tracking checks, 5 terrain-outage checks, controlled slow-upstream comparison and live browser checks. Co-authored-by: ItzDESTAQ <[email protected]> Co-authored-by: Sameh Khamis <[email protected]>
This commit is contained in:
1 parent
4e99f40488
commit
db49edf363
8 files changed
+254
-32
No files matched your search
@@ -17,7 +17,7 @@
|
||||
// single request much past ~700-1500 points (depending on coordinate
|
||||
// precision) risks a raw socket-level 431 *before* the proxy's own
|
||||
// request handler runs. So every network request this module issues is
|
||||
// chunked at CHUNK_SIZE (200 points), well under that ceiling, and
|
||||
// chunked at CHUNK_SIZE (64 points), well under that ceiling, and
|
||||
// chunks are sent SEQUENTIALLY (not in parallel) to keep this client
|
||||
// well-behaved against a single dev-server proxy.
|
||||
// 2. The proxy's disk cache is keyed by the raw `points` query string, with
|
||||
@@ -32,7 +32,9 @@
|
||||
import { ensureGeoidReady, geoidHeight } from './geoid.js';
|
||||
|
||||
/** Max points per outgoing request to `/api/terrain/heights` (see file header, point 1). */
|
||||
const CHUNK_SIZE = 200;
|
||||
// Match the server's upstream batch so sequential upstream work also fits
|
||||
// within this client's 30-second request deadline when Re:Earth slows.
|
||||
const CHUNK_SIZE = 64;
|
||||
|
||||
/** Avoid repeatedly hitting a known-failing proxy from warm fallback reads. */
|
||||
const GEOID_FALLBACK_COOLDOWN_MS = 60_000;
|
||||
@@ -116,7 +118,7 @@ async function fetchChunk(chunk) {
|
||||
// the response's own lon/lat fields to re-match — those are also present
|
||||
// for callers who want them, but this module doesn't need them.
|
||||
for (let i = 0; i < chunk.length; i += 1) {
|
||||
const ellipsoid = Number(body.results[i]?.ellipsoid);
|
||||
const ellipsoid = body.results[i]?.ellipsoid;
|
||||
if (!Number.isFinite(ellipsoid)) throw new Error(`non-finite ellipsoid height at index ${i}`);
|
||||
out.set(chunk[i].key, ellipsoid);
|
||||
}
|
||||
@@ -145,7 +147,7 @@ function geoidFallback(lat, lon, sourceOrthometricM) {
|
||||
* - Results already warm in the in-memory cache are returned without any
|
||||
* network call.
|
||||
* - Remaining (deduplicated) coordinates are sent to `/api/terrain/heights`
|
||||
* in sequential chunks of <=200 points.
|
||||
* in sequential chunks of <=64 points.
|
||||
* - If a chunk request fails (network error, non-ok HTTP, malformed body),
|
||||
* every point in THAT chunk falls back to geoid math
|
||||
* (`sourceOrthometricM + geoidHeight` or `geoidHeight` alone) rather than
|
||||
|
||||
Reference in new issue
Block a user