Suppress the "The operation is insecure" exception in Firefox private browsing
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: 2.3.0, 2.8.1, but should continue to exist
**browser**: Firefox 99.0.1
### Steps to Trigger Behavior
1. Open a website with mapbox-gl-js private browsing mode
2. Observe
### Link to Demonstration
https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage states that `Furthermore, because CacheStorage requires file-system access, it may be unavailable in private mode in Firefox.`
We observe that the call to `window.caches.open` in https://github.com/mapbox/mapbox-gl-js/blob/main/src/util/tile_request_cache.js can throw an `SecurityError: The operation is insecure` per the above when we open an app in private mode.
The code is robust enough that things still work, but we still pollute the console with an error (either mapbox-gl-js just does it or common error-logging code would cause that to happen, I think through intercepting `console.warn` calls but am not 100% sure) and report things to error-tracking tools, so it would be nice if we could instead try-catch and swallow that error in this situation.
### Expected Behavior
Error-reporting tools don't get a SecurityError when this happens.
### Actual Behavior
Said tools do get such an error.
Contributor guide
Research direction
Start in src/util/tile_request_cache.js, where the issue identifies the window.caches.open call, and reproduce the behavior in Firefox private browsing. Trace how the SecurityError is handled and verify that this expected browser limitation no longer reaches error-reporting tools while normal cache behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100