fix(geolocate): guard permission query against synchronous throws#861
Conversation
- Guard permissions.query() against a synchronous throw (partial API, CSP, private browsing) by wrapping it in try/catch and deferring a reset via queueMicrotask, matching the no-API fallback. .catch() alone only handles async rejections. - Add tests for the rejected-promise (.catch) and synchronous-throw branches of handleGeolocateError.
✅ Deploy Preview for geolibre-app ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
More reviews will be available in 22 minutes and 34 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⚡ Cloudflare Pages preview
|
Code reviewOverall the implementation is correct, the edge case is real, and the two new tests pin both branches. No bugs, no security issues, no performance concerns. Three minor observations below. BugsNone found. SecurityNone found. PerformanceNone found. Quality
CLAUDE.mdNo CLAUDE.md guidelines apply to these files specifically (no new UI strings, no MapLibre control styling changes, no new external hosts). |
Summary
Follow-up to #858 (merged). The final round of automated review on that PR landed two items after it was already merged, so this small PR carries them forward.
Changes
permissions.query()against a synchronous throw. InhandleGeolocateError,.catch()only intercepts async rejections. Some Permissions API implementations can throw synchronously (partial support, CSP restrictions, Firefox private browsing), which would escape the handler as an unhandled error. Wrap the query intry/catchand fall back to a deferred reset viaqueueMicrotask— consistent with the existing no-Permissions-API path, and it avoids tearing down the control mid error-dispatch..catch) branch and the synchronous-throw branch ofhandleGeolocateError.Verification
tests/map-controller.test.ts— 35 pass (9 in the geolocate recovery suite).tsc -bclean.Relates to #839.