fix(street-level): pause Street View details retries after a failure

Maintainer follow-up to #966 review:

- A failed panorama-details lookup now waits DETAILS_RETRY_COOLDOWN_MS
  (5 s) per panorama before a view event can retry it, so dragging the
  view after a failure no longer issues a lookup on every pov change. A
  success clears the pause; one panorama's failure does not delay another.
- SECURITY.md notes that allowing maps.googleapis.com in script-src also
  trusts its JSONP endpoints, an accepted limitation alongside the
  existing 'unsafe-eval' allowance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Sameh KhamisandClaude Opus 5.5 committed 2026-10-08 10:38:01 -07:00
1 parent ef396655fc
commit 84f634efb0
5 files changed
+65 -6

No files matched your search

@@ -1,4 +1,5 @@
import {
DETAILS_RETRY_COOLDOWN_MS,
GOOGLE_PROVIDER_ID,
KEY_REJECTED_MESSAGE,
NO_ANSWER_MESSAGE,
@@ -50,6 +51,8 @@ export function createGoogleViewer({ loader, getService, render } = {}) {
const described = new Map();
/** Panorama ids whose lookup is in flight. */
const lookingUp = new Set();
/** Panorama id → earliest retry time after a failed details lookup. */
const retryAfter = new Map();
const listeners = new Set();
function requestRender() {
@@ -81,11 +84,12 @@ export function createGoogleViewer({ loader, getService, render } = {}) {
/**
* Look up a panorama's date, photographer and address once; the pose
* already out is sent again with them. A failed lookup is asked again on
* the next event.
* already out is sent again with them. After a failure, view events can
* retry once the cooldown expires.
*/
async function describe(panoId) {
if (described.has(panoId) || lookingUp.has(panoId)) return;
if (Date.now() < (retryAfter.get(panoId) ?? 0)) return;
lookingUp.add(panoId);
try {
service ||= getService
@@ -93,7 +97,9 @@ export function createGoogleViewer({ loader, getService, render } = {}) {
: new (await ensureLibrary()).StreetViewService();
const { data } = await service.getPanorama({ pano: panoId });
described.set(panoId, metaFrom(data));
retryAfter.delete(panoId);
} catch {
retryAfter.set(panoId, Date.now() + DETAILS_RETRY_COOLDOWN_MS);
return;
} finally {
lookingUp.delete(panoId);