actualbudget/actual · error

Geolocation is not supported by this browser

Error message

Geolocation is not supported by this browser

What it means

BrowserGeolocationAdapter.getCurrentPosition checks navigator.geolocation before calling the browser API and throws 'Geolocation is not supported by this browser' when it is absent. This is a capability guard: some browsers/contexts do not expose the Geolocation API, so the adapter fails fast instead of throwing an opaque TypeError.

Source

Thrown at packages/desktop-client/src/payees/location-adapters.ts:39

    coordinates: LocationCoordinates,
  ): Promise<string>;
  getLocations(payeeId: string): Promise<PayeeLocationEntity[]>;
  deleteLocation(locationId: string): Promise<void>;
  getNearbyPayees(
    coordinates: LocationCoordinates,
    maxDistance: number,
  ): Promise<NearbyPayeeEntity[]>;
};

/**
 * Browser implementation of geolocation using the Web Geolocation API
 */
export class BrowserGeolocationAdapter implements GeolocationAdapter {
  async getCurrentPosition(
    options: PositionOptions = {},
  ): Promise<LocationCoordinates> {
    if (!navigator.geolocation) {
      throw new Error('Geolocation is not supported by this browser');
    }

    const defaultOptions: PositionOptions = {
      enableHighAccuracy: true,
      timeout: 15000, // 15 second timeout
      maximumAge: 60000, // Accept 1-minute-old cached position
    };

    const position = await new Promise<GeolocationPosition>(
      (resolve, reject) => {
        navigator.geolocation.getCurrentPosition(resolve, reject, {
          ...defaultOptions,
          ...options,
        });
      },
    );
    return {
      latitude: position.coords.latitude,

View on GitHub (pinned to d4334cb6e6)

Solutions

  1. Serve the app over HTTPS (or localhost) so the browser exposes navigator.geolocation
  2. Feature-check navigator.geolocation before invoking and show a graceful fallback UI
  3. For iframes, add allow="geolocation" to the iframe element
  4. In Electron/webview builds, enable the geolocation permission handler or supply a custom GeolocationAdapter

Example fix

// before
const coords = await adapter.getCurrentPosition();
// after
if (!('geolocation' in navigator)) {
  toast('Location is unavailable in this browser');
} else {
  const coords = await adapter.getCurrentPosition();
}
Defensive patterns

Strategy: fallback

Validate before calling

if (typeof navigator === 'undefined' || !('geolocation' in navigator)) {
  console.warn('Geolocation unavailable — offer manual location entry');
}
const isSecureContextOk = typeof window !== 'undefined' && window.isSecureContext;

Type guard

const supportsGeolocation = (nav: Navigator | undefined): nav is Navigator & { geolocation: Geolocation } =>
  !!nav && 'geolocation' in nav && typeof nav.geolocation.getCurrentPosition === 'function';

Try / catch

try {
  const coords = await adapter.getCurrentPosition();
} catch (err) {
  if (err.message === 'Geolocation is not supported by this browser') {
    promptForManualLocation(); // e.g. search by payee name/city instead
  } else throw err;
}

Prevention

When it happens

Trigger: Calling position/getCurrentPosition in a browser without Geolocation support, in a non-secure (http://) context where geolocation is disabled, inside an iframe without allow="geolocation", or in environments where navigator is stubbed.

Common situations: Insecure origins (plain HTTP) where Chrome/Firefox disable geolocation; embedded webviews (some Electron/webview configs) lacking the API; feature-detection being skipped during SSR or tests with mocked globals.

Related errors


AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29). Data as JSON: /api/errors/b94b4d70579bee9c. Report an issue: GitHub.