appsmithorg/appsmith · error · GeoLocationError
${error.message}
Error message
${error.message} What it means
Re-thrown inside getCurrentLocationSaga's catch block. After a toast is shown, if the caught error is specifically a GeolocationPositionError, the saga sanitises it (extracting code+message only, because the GeolocationPositionError class is not structured-cloneable into the eval worker) and re-wraps it as GeoLocationError with the human message. The accompanying array carries the {code, message} object so callers can branch on permission-denied vs unavailable.
Source
Thrown at app/client/src/sagas/ActionExecution/geolocationSaga.ts:141
const { payload: actionPayload } = action;
try {
const location: GeolocationPosition = yield call(
getUserLocation,
actionPayload.options,
);
const currentLocation = extractGeoLocation(location);
yield put(setUserCurrentGeoLocation(currentLocation));
return currentLocation;
} catch (error) {
yield call(showToastOnExecutionError, (error as Error).message);
if (error instanceof GeolocationPositionError) {
const sanitizedError = sanitizeGeolocationError(error);
throw new GeoLocationError(sanitizedError.message, [sanitizedError]);
}
}
}
let watchId: number | undefined;
export function* watchCurrentLocation(
action: TWatchGeoLocationDescription,
_: EventType,
triggerMeta: TriggerMeta,
) {
const { payload: actionPayload } = action;
if (watchId) {
// When a watch is already active, we will not start a new watch.
// at a given point in time, only one watch is active
yield call(
showToastOnExecutionError,View on GitHub (pinned to 8cd9021c24)
Solutions
- Serve the app over HTTPS (or localhost) — geolocation is a secure-context-only API.
- Have the user clear the site's location permission and re-grant it.
- Pass options.timeout / enableHighAccuracy thoughtfully; raise timeout for slow GPS.
- In the JS object, catch the error and inspect the code to show a helpful message instead of the raw toast.
Example fix
// before
const loc = await getCurrentPosition();
// after
try {
const loc = await getCurrentPosition({ enableHighAccuracy: true, timeout: 10000 });
} catch (e) {
showAlert('Location unavailable: ' + (e?.responseData?.[0]?.code === 1 ? 'permission denied' : 'unavailable'));
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!('geolocation' in navigator)) {
showAlert('Geolocation not supported by this browser', 'error');
return;
}
if (window.isSecureContext === false) {
showAlert('Geolocation requires HTTPS', 'error');
return;
} Type guard
function isGeolocationPositionError(e: unknown): e is GeolocationPositionError {
return typeof e === 'object' && e !== null && 'code' in e && 'message' in e;
} Try / catch
try {
const loc = await getCurrentPosition({ enableHighAccuracy: true, timeout: 10000 });
} catch (e) {
const code = e?.responseData?.[0]?.code;
const hint = code === 1 ? 'permission denied' : code === 2 ? 'unavailable' : code === 3 ? 'timed out' : 'failed';
showAlert('Location ' + hint, 'error');
} Prevention
- Serve the app over HTTPS or on localhost so geolocation is available.
- Tell users how to re-grant location permission in their browser settings.
- Pass a sensible options.timeout; raise it on slow devices.
- Branch on the error code to give actionable messages.
When it happens
Trigger: Browser geolocation fails: code 1 PERMISSION_DENIED (user blocked or browser setting off), code 2 POSITION_UNAVAILABLE (no GPS / device offline), code 3 TIMEOUT (options.timeout exceeded).
Common situations: App served over HTTP (geolocation requires secure context); first-time permission denied and never re-prompted; testing on desktop with location disabled; user on a device with no location hardware.
Related errors
AI-assisted analysis of appsmithorg/appsmith@8cd9021c24 (2026-08-12).
Data as JSON: /api/errors/0229c01e70f7b0a5.
Report an issue: GitHub.