I'm experiencing an issue in a React application with getCurrentPosition (example code below) where I will experience bouts of timeout failures.
navigator.geolocation.getCurrentPosition(
p => console.log(p),
e => console.log(e),
{
timeout: 7000,
enableHighAccuracy: false,
maximumAge: 1000 * 60 * 60 * 24
}
)
It's quite inconsistent, and succeeds a lot, but when it does happen, it will also occur when just pasting the command in the dev tools console in Chrome, Brave, and Firefox (tested only on MacOS so far), regardless of what domain I'm currently navigated to there. Also when it does fail it fails repeatedly, despite page refreshing.
Edit: For clarification, the issue is sporadic and reproducible from the F12 console (literally was able to get it just now from this page; though had to reload once to see it fail), but within the codebase, it's used like the below
export function getBrowserLocation() {
return new Promise((res, rej) => {
navigator.geolocation.getCurrentPosition(res, rej, options)
});
}
// inside a component
<button onClick={async () => {
try {
const location = await getBrowserLocation();
// do something with location
} catch (e) {
// error handling e.g. console.log(e)
}}}>GetLocation</button>