-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle 204 No content responses correctly as an empty tile and avoid trying to decode the response #9304
Comments
It seems we are trying to read the content of a 204 in the same way as a 200. It seems reasonable to me that we treat 204 responses as they should be, as empty content and avoid throwing the error. Some background in #1800 which backs up this request. |
204 means |
I think I read two bugs here:
cc @mapbox/gl-js @mapbox/gl-native |
Any updates? |
This is hitting me too using hillshading mbtiles datasets from https://openmaptiles.com/. We're using a custom tile server that responds with 204 No Content if the tile url is valid but no hillshading data is present for that tile. |
Looked around a bit: JS / web:
Native:
Looking at the code I don't think 204 is specifically handled and mostly seems to depend on the data being zero length? I was under the impression 204 worked fine (force tile to be empty), but this issue implies there isn't explicit support for this in many clients. After briefly looking at the different renderers, I'm not so sure anymore whether it's a good idea to depend on these status code to convey meaning in tile-servers right now.. |
I have an Nginx server with static tile files in PBF format. Therefore, the assets are vectors, not images. Libraries like MapLibre GL and Mapbox GL can handle missing files (204 or any other response status) and use the vectors below to render them at a higher zoom level. The main difference between a 204 status and others like 4xx or 50xx is that browsers do not throw errors. For instance, if the server sends a 404 response, the browser will throw an error in the console, even though the libraries know what to do to render the missing tile. My server sends a 204 status for all 404 requests and asks the browser to cache it. This makes sense as there are no errors in the console and the 204 status is cached. |
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
maptiler/tileserver-gl#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
Link to Demonstration
https://jsbin.com/loyajulodu/edit?html,output
Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: