Skip to content
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

Suppress error messages for missing tiles #1800

Closed
lucaswoj opened this issue Dec 4, 2015 · 27 comments
Closed

Suppress error messages for missing tiles #1800

lucaswoj opened this issue Dec 4, 2015 · 27 comments

Comments

@lucaswoj
Copy link
Contributor

lucaswoj commented Dec 4, 2015

There is log spew about missing tiles, though it is valid for a tile endpoint to return a 404 to express "no data". We should suppress these error messages.

ref #1549

@rbonillajr
Copy link

This error causes me other component failures

for examples this add more and more delete button

image

@gertcuykens
Copy link

Or maybe add the ability to import stuff in the original tile set street-v6 in studio so you don't have to make a incomplete data set with no tiles in the first place?

Ps also note that you can not disable does 404's in chrome console, so worker debug messages end up in between does 404.

@mourner
Copy link
Member

mourner commented May 18, 2016

If we supress all 404 errors, how do we handle situations with e.g. a typo in the url leading to all tiles being 404? That would go unnoticeable.

@jfirebaugh
Copy link
Contributor

404s will still be visible in the network page of developer tools (and for unexpected errors like bad URLs, visible as missing tiles in the map). This ticket is about suppressing the extra logging to the JS console that is happening right now. I don't think that there's a way to programmatically distinguish "expected" and "unexpected" 404s, so I think we'll accept that "unexpected" 404s only get logged to the normal places.

@jfirebaugh
Copy link
Contributor

Also, the long-term fix here is to encourage using HTTP 204 "No Content" response in tile APIs to indicate lack of a tile at the requested coordinates, and reserving 404 for real unexpected errors. I've ticketed this internally for future versions of the Mapbox tile API.

@lucaswoj
Copy link
Contributor Author

We will address this issue through using HTTP 204 "No Content" codes and implementing #1775

@jfirebaugh
Copy link
Contributor

It's going to be awhile before we can rely on 204, and this comes up often with @mapbox/support. Let's add the suppression.

@jfirebaugh jfirebaugh reopened this Sep 12, 2016
@Scarysize
Copy link

Scarysize commented Oct 18, 2016

What would be the correct way to suppress the error? Not calling the callback with the err object here (?):

@mollymerp mollymerp added this to the Frankfurt milestone Oct 24, 2016
@lucaswoj lucaswoj removed this from the Frankfurt milestone Nov 21, 2016
@redbmk
Copy link

redbmk commented Dec 15, 2016

Maybe this isn't the right place to be posting this, but I haven't found anywhere explaining why I'm even getting these 404s in the first place. I created a map using mapbox studio and am simply using the style address provided. I'm authenticating with the API key given, and the map is rendering perfectly fine. Somehow I'm still getting hundreds of 404 messages from missing tiles clogging up my console, which makes it difficult to notice relevant errors.

Does anyone have a clear explanation of what causes these in the first place and how to fix it at the source, within Mapbox Studio? I had created the tileset using tippecanoe, if that makes a difference.

@andrewharvey
Copy link
Collaborator

I had created the tileset using tippecanoe, if that makes a difference.

If the data is limited to a small geographic region, tiles outside this region will currently return 404 I believe. Is that what you're seeing?

@redbmk
Copy link

redbmk commented Dec 15, 2016

Yeah, looks like it. This particular map isn't actually related to any geographic location so I'm just using a blank background instead of the globe. I think the dataset is about the size of Germany. And yeah if I zoom into the middle of it I stop getting 404s.

Is there a workaround or a better way to display small datasets?

@Scarysize
Copy link

@redbmk only way we found, is explained in my my comment above

@mvanroon
Copy link

I am on version 0.38.0 and errors are still being thrown.

Also the following code logs 'Error' (not 'Error: Not Found') for me:

map.on('error', e => {
  console.log(e.error);
});

@matthojo
Copy link

matthojo commented Jun 22, 2017

I am also getting this error. I have looked at https://api.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.js and I cannot see any of the if (err.status !== 404) changes (from #4446) in the source - which would indicate why the error is appearing.
Updated based on mvanroon's correction.

@mvanroon
Copy link

mvanroon commented Jun 22, 2017

that's because the code is minified: it does say 404!==i.status somewhere

@matthojo
Copy link

@mvanroon Apologise, you are correct. I'll keep digging!

@jfirebaugh
Copy link
Contributor

This issue refers to suppressing error messages produced by Mapbox GL JS itself, with the text "Error: Not Found". It's expected that error messages like "Failed to load resource: the server responded with a status of 404" still appear: those messages are logged by the browser itself, and there's no way for Mapbox GL JS to suppress them. To suppress those message, the tile server needs to return HTTP 204 "No Content" rather than 404. (We have an internal issue tracking making that change for the Mapbox Tile API.)

@skaletech
Copy link

For anyone who doesn't want to wait for a tile server fix and doesn't mind suppressing all 404 errors:

var consoleerror = console.error;
console.error = function (err) {
    if (typeof (err.stack) != 'undefined' && err.stack.includes('at Actor.receive (https://api.tiles.mapbox.com/')) {
        return;
    } else {
        consoleerror(err);
    }
}

@redbmk
Copy link

redbmk commented Jan 31, 2018

@skaletech Are you not able to do something like that with map.on('error'...) instead of overriding console.error?

@skaletech
Copy link

skaletech commented Jan 31, 2018

map.on('error'...) does not seem to fire when an Actor.receive error occurs. I think that is because the mapbox code is just calling console.error()

This is just a hack to clear your console from a bunch of garbage errors.

@redbmk
Copy link

redbmk commented Jan 31, 2018

I just tested this code with v0.42.2 and instead of a console error on those 404s I get an event that has an error property (among other things) logged to the console:

map.on('error', event => console.log(event))

@skaletech
Copy link

Sorry, I'm on the bleeding edge, 44.0. I did not get any such error, it is definitely going through console.error()

@redbmk
Copy link

redbmk commented Jan 31, 2018

Hmm, the other difference is I'm using a custom tile server and just telling it to return 404s. Not sure what else would be different about your setup. I wouldn't mind playing around with it if you set up a simple demo in e.g. jsfiddle. It looks like the code should let you intercept those errors, so I'm not sure why it doesn't seem to be working.

@skaletech
Copy link

We're using something other than mapbox that gives a 404 when the tile is empty. I'm not really interested in fixing the issue, since I have something that works fine for my use case.

The only reason I would want to see 404 in my JS console is if the entire layer was returning 404 because of a configuration issue, but that's not an issue since it would be visible.

I just wanted to post my work around in case someone else is getting superfluous errors. If the map.on('error') thing worked for me, I would have used it.

@redbmk
Copy link

redbmk commented Jan 31, 2018

Gotcha, no worries then. FWIW, I find returning a 204 (No Content) doesn't end up throwing any errors in the console.

@darkl1ght
Copy link

darkl1ght commented Mar 13, 2021

Hi,

Any update on how to suppress this issue?

I still get the 404 error for the "Tile not found" error.

image_ref1

image_ref2

ref3

I don't want these error messages to pop up on the console.
The map loads just fine, it's the tilesets that are causing this issue, and once the screen is on the corner areas of the tileset, these errors come in a whole bunch.

Any help appreciated.
I am working on Angular to load maps and tileset data from the APIs, so any suggestions/modifications there would be helpful too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests