mapbox / mapbox/mapbox-gl-js

Missing Mapbox access token for a Mapbox source does not trigger the map.on('error') event

Open
#6,528 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle: needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

mapbox-gl@0.44.2:

### Steps to Trigger Behavior

1. Instantiate a map
2. Bind to the mapbox-gl on error event
3. Do not specify a Mapbox access token
4. Load a style JSON with a source pointed at a mapbox:// endpoint
5. Thrown error caught by console but does not trigger error event

### Expected Behavior

Mapbox auth errors should trigger the [map.on('error')](https://www.mapbox.com/mapbox-gl-js/api/#map.event:error) event similar to all other Mapbox errors.

### Actual Behavior

Error event not triggered - caught instead by console.

### Additional Notes

According to the [error event documentation](https://www.mapbox.com/mapbox-gl-js/api/#map.event:error), mapbox-gl should use the error event instead of throwing an error. A link to where the error is thrown in the code [src/util/mapbox.js](https://github.com/mapbox/mapbox-gl-js/blob/03680eb57489cf442f8c538141ea27c73d98d532/src/util/mapbox.js#L29).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/util/mapbox.js at the linked error location and reproduce the documented steps using a mapbox:// source without an access token. Trace how the authentication error is handled relative to map.on('error'). Done means the missing-token error triggers the map error event instead of only being caught by the console.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.