mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
fix(terrain): bound each height request to one upstream chunk
This commit is contained in:
1 parent
de2138e84c
commit
7860cbf59e
4 files changed
+53
-24
No files matched your search
@@ -20,8 +20,8 @@ import { admitSameSiteKeyless } from './common/same-site.js';
|
||||
* cache and serve-stale shape. Cache entries and stale fallback are keyed per
|
||||
* 5dp point, so reordered and partially overlapping batches reuse prior work.
|
||||
* Only missing/stale points go upstream; the response is rebuilt in exact
|
||||
* request order. Larger requests are chunked sequentially, and one failing
|
||||
* chunk does not discard the chunks that resolved.
|
||||
* request order. Each request is bounded to one 64-point upstream chunk;
|
||||
* larger client workloads are split by the browser terrain service.
|
||||
*
|
||||
* Bounds, because every distinct 5dp point is its own key: coordinates must be
|
||||
* in WGS-84 range (rejected at parse), the point cache has an entry ceiling
|
||||
@@ -55,7 +55,7 @@ export function terrainHeightsProxy(options = {}) {
|
||||
// 2026-08-21). 64 points costs 5.6-12 s, inside the timeout at both ends of
|
||||
// that range.
|
||||
const UPSTREAM_CHUNK = 64;
|
||||
const MAX_POINTS = 2000;
|
||||
const MAX_POINTS = UPSTREAM_CHUNK;
|
||||
/**
|
||||
* Entry ceiling for the point cache, and with it the file written from it.
|
||||
*
|
||||
@@ -255,7 +255,6 @@ export function terrainHeightsProxy(options = {}) {
|
||||
res.end(JSON.stringify({ error: 'Rate limit exceeded' }));
|
||||
return;
|
||||
}
|
||||
await loadDiskOnce();
|
||||
const parsedUrl = new URL(req.url || '', 'http://internal');
|
||||
const rawPoints = parsedUrl.searchParams.get('points');
|
||||
const points = parseTerrainPoints(rawPoints);
|
||||
@@ -267,12 +266,13 @@ export function terrainHeightsProxy(options = {}) {
|
||||
return;
|
||||
}
|
||||
if (points.length > MAX_POINTS) {
|
||||
send(500, {
|
||||
send(413, {
|
||||
error: `too many points (${points.length}); max ${MAX_POINTS} per request`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await loadDiskOnce();
|
||||
const outcome = await resolveTerrainHeightRequest({
|
||||
points,
|
||||
cache: mem,
|
||||
|
||||
Reference in new issue
Block a user