mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
keep cancelled outline and search asks free during the Nominatim probe
Recheck the caller's signal right after the capability probe on every path, so an ask cleared while the probe is pending starts no outline or last-resort search request, whether the probe says configured, unknown or not configured.
This commit is contained in:
1 parent
f32ab5446b
commit
3824b4ebfc
4 files changed
+69
-7
No files matched your search
@@ -53,3 +53,31 @@ test('the last-resort route is skipped when the server reports Nominatim unconfi
|
||||
const on = await run(true);
|
||||
assert.ok(on.includes('/api/geocode'), on.join(','));
|
||||
});
|
||||
|
||||
test('a search cancelled while the Nominatim probe is pending starts no last-resort request', async () => {
|
||||
let release;
|
||||
const held = new Promise((resolve) => {
|
||||
release = resolve;
|
||||
});
|
||||
const asked = [];
|
||||
const controller = new AbortController();
|
||||
const search = createDefaultPlaceSearch({
|
||||
endpoints: { photon: null },
|
||||
fetchImpl: async (url) => {
|
||||
const path = new URL(String(url), 'http://local.test').pathname;
|
||||
asked.push(path);
|
||||
if (path === '/api/geocode/status') {
|
||||
controller.abort();
|
||||
await held;
|
||||
return Response.json({ configured: true });
|
||||
}
|
||||
return Response.json({ status: 'ZERO_RESULTS', results: [] });
|
||||
},
|
||||
});
|
||||
const pending = search.geocode('nowhere-cancelled', {
|
||||
signal: controller.signal,
|
||||
});
|
||||
release();
|
||||
await pending.catch(() => null);
|
||||
assert.ok(!asked.includes('/api/geocode'), asked.join(','));
|
||||
});
|
||||
Reference in new issue
Block a user