mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
fix(street-level): run at most six Mapillary tile fetches at once
Tiles a camera move leaves behind keep downloading after the client drops them; the cap bounds their memory and quota, as main's proxy did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
35bfe203a6
commit
c18af6ad1c
3 files changed
+46
-3
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
import {
|
||||
TILE_MAX_BYTES,
|
||||
TILE_MEMORY_BUDGET_BYTES,
|
||||
TILE_UPSTREAM_CONCURRENCY,
|
||||
TILE_TTL_MS,
|
||||
_resetTileCacheForTest,
|
||||
_tileMemoryForTest,
|
||||
@@ -389,6 +390,26 @@ test('identical concurrent tile requests share one upstream fetch', async () =>
|
||||
);
|
||||
});
|
||||
|
||||
test('at most a few upstream fetches run at once; the rest wait their turn', async () => {
|
||||
let release;
|
||||
const gate = new Promise((resolve) => (release = resolve));
|
||||
await withUpstream(
|
||||
async () => (await gate, ok()),
|
||||
async ({ calls, call }) => {
|
||||
const tiles = TILE_UPSTREAM_CONCURRENCY + 4;
|
||||
const pending = Array.from({ length: tiles }, (_, i) =>
|
||||
call('/api/mapillary/tiles', `/coverage/14/${i}/3`),
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
assert.equal(calls.length, TILE_UPSTREAM_CONCURRENCY);
|
||||
release();
|
||||
const done = await Promise.all(pending);
|
||||
assert.ok(done.every((res) => res.statusCode === 200));
|
||||
assert.equal(calls.length, tiles, 'the waiting ones ran too');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('a tile held in memory past its TTL is fetched again', async (t) => {
|
||||
await withUpstream(
|
||||
() => ok(),
|
||||
|
||||
Reference in new issue
Block a user