Skip to content

Commit 6d7cf31

Browse files
CopilotMrAlders0n
andcommitted
Add error handling and fix accuracy variable closure
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
1 parent 6328627 commit 6d7cf31

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

content/wardrive.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,19 @@ async function sendPing(manual = false) {
482482
}, STATUS_UPDATE_DELAY_MS);
483483

484484
state.meshMapperTimer = setTimeout(async () => {
485-
await postToMeshMapperAPI(lat, lon);
485+
// Capture accuracy in closure to ensure it's available in nested callback
486+
const capturedAccuracy = accuracy;
487+
488+
try {
489+
await postToMeshMapperAPI(lat, lon);
490+
} catch (error) {
491+
console.error("MeshMapper API post failed:", error);
492+
// Continue with map refresh and status update even if API fails
493+
}
486494

487495
// Update map after API post to ensure backend updated
488496
setTimeout(() => {
489-
if (accuracy && accuracy < GPS_ACCURACY_THRESHOLD_M) {
497+
if (capturedAccuracy && capturedAccuracy < GPS_ACCURACY_THRESHOLD_M) {
490498
scheduleCoverageRefresh(lat, lon);
491499
}
492500

0 commit comments

Comments
 (0)