mapbox / mapbox/mapbox-gl-js

Handle 204 No content responses correctly as an empty tile and avoid trying to decode the response

Open
#9,304 8 comments 12 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

Tileserver-GL started sending empty 204 responses if a tile is not available.
https://github.com/maptiler/tileserver-gl/blob/master/src/serve_data.js#L45
https://github.com/maptiler/tileserver-gl/pull/339

Mapbox-gl-js doesn't handle this very good. It creates an error message every time a tile is fetched and doesn't cache the server response (but the browser maybe does).

**mapbox-gl-js version**:
Since 1.7.0.
1.6.0 is not affected
**browser**:
Chrome, Firefox
### Steps to Trigger Behavior

1. Open the Demonstration
2. See Errors in Console
3. Scroll in and out. The 204 requests are repeated every time

### Link to Demonstration

https://jsbin.com/loyajulodu/edit?html,output

### Expected Behavior
* 204 response don't create a console error
* 204 response are cached inside mapbox-gl-js
### Actual Behavior
* 204 response create a console error
```
Error: Could not load image because of The source image could not be decoded.. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.
at ajax.js:280
```
* 204 response are always passed to the Browser. The browser maybe caches it.

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 the response handling near ajax.js:280 and reproduce the issue using the linked demonstration in Chrome or Firefox. Trace how a 204 response reaches image decoding, then verify that it is treated as an empty tile without a console error and is cached by mapbox-gl-js rather than requested repeatedly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.