fix: Locate returning 429/504 and silently-empty halal results
The Locate tab (mosque/halal/cemetery) hardcoded a single public Overpass API endpoint. Public Overpass instances are individually flaky under load — confirmed live: the same query returned 429 from one mirror and 504 from the primary a few minutes apart, with no retry or fallback, surfacing as a hard failure to the user. Added a short fallback chain (overpass-api.de, then overpass.kumi.systems) that retries on 429/503/504 and only reports failure once every mirror has failed, with an honest 'try again shortly' message distinct from a genuine empty-results state. A third mirror (overpass.osm.ch) was tried too but dropped after finding something worse than a failure: it returned a 'successful' 200 with 0 results for a query the other two mirrors correctly answer with 30 (diet:halal=yes near Kuala Lumpur) — a stale/incomplete regional replica that would have short-circuited the fallback loop and silently told users nothing was nearby when it actually was. e2e-khairat-lifestyle.cjs gains a tightened assertion (halal search must return >0 results at a known-good test coordinate, not just 'results or empty') to catch this exact silently-wrong-mirror class of bug in the future, plus a filter so expected fallback-path 429/504s don't fail the 'no console errors' check — those are the retry mechanism working, not a bug. Verified live against the deployed app: 30 real results returned.
This commit is contained in:
@@ -69,14 +69,25 @@ async function main() {
|
||||
const timesInOrder = await page.locator('.times-list').innerText();
|
||||
record('Prayer Times: computes all 6 times for Kuala Lumpur', fajrVisible && /Fajr[\s\S]*Sunrise[\s\S]*Dhuhr[\s\S]*Asr[\s\S]*Maghrib[\s\S]*Isha/.test(timesInOrder), timesInOrder.replace(/\n/g, ' '));
|
||||
|
||||
// ── Locate (mosque search via live OpenStreetMap Overpass) ──
|
||||
// ── Locate (mosque + halal search via live OpenStreetMap Overpass) ──
|
||||
await gotoTab(page, 'Locate');
|
||||
await page.waitForTimeout(500);
|
||||
await page.locator('button.btn-primary', { hasText: 'Search nearby' }).click();
|
||||
await page.waitForTimeout(8000); // live Overpass API call
|
||||
await page.waitForTimeout(10000); // live Overpass API call, across mirrors if the first is down
|
||||
const locateResultOrEmpty = await page.locator('.results-list, .empty').isVisible().catch(() => false);
|
||||
record('Locate: mosque search completes (real results or honest empty state)', locateResultOrEmpty);
|
||||
|
||||
// Halal food specifically: OSM tagging is sparse for this category
|
||||
// globally, but Kuala Lumpur at this test coordinate is known to have
|
||||
// real diet:halal=yes data (~30 results) — asserting a non-zero count
|
||||
// here catches a mirror silently returning an empty-but-"successful"
|
||||
// response, which looks identical to a legitimate empty search otherwise.
|
||||
await page.locator('.category-toggle button', { hasText: 'Halal food' }).click();
|
||||
await page.locator('button.btn-primary', { hasText: 'Search nearby' }).click();
|
||||
await page.waitForTimeout(10000);
|
||||
const halalResultCount = await page.locator('.result-row').count();
|
||||
record('Locate: halal food search returns real results at a known-good test location', halalResultCount > 0, `${halalResultCount} results`);
|
||||
|
||||
// ── Quran ──
|
||||
await gotoTab(page, 'Quran');
|
||||
await page.waitForTimeout(2000);
|
||||
@@ -136,7 +147,12 @@ async function main() {
|
||||
record('Neighbourhood: a second account joining by code sees the same posts', secondSeesPost);
|
||||
await secondContext.close();
|
||||
|
||||
record('No uncaught JS console errors during full session', consoleErrors.length === 0, consoleErrors.slice(0, 5).join(' || '));
|
||||
// A 504/429/503 while trying one Overpass mirror before falling through to
|
||||
// the next is the fallback mechanism working as designed, not a bug — the
|
||||
// browser still logs the failed fetch as a console error either way, so
|
||||
// filter those specific expected-noise lines out of this assertion.
|
||||
const realConsoleErrors = consoleErrors.filter(e => !/overpass.*(429|503|504)|Gateway Timeout|Too Many Requests/i.test(e));
|
||||
record('No uncaught JS console errors during full session', realConsoleErrors.length === 0, realConsoleErrors.slice(0, 5).join(' || '));
|
||||
|
||||
await browser.close();
|
||||
const passCount = results.filter(r => r.pass).length;
|
||||
|
||||
Reference in New Issue
Block a user