Unhandled Error in CesiumTerrainProvider


When I start my app at the full globe view and then zoom in to a specific area, I can pretty reliably cause this error.
It causes Cesium (and thus my app) to freeze; reloading the page is the only way to recover.
Problem is, even a global error handler doesn’t catch it. (Claude says it’s in async code from Cesium that my main thread can’t intercept, FWIW)

I tried a specific intercept, per some older threads on the forum:

    const terrain = new Terrain(createWorldTerrainAsync()); // https://cesium.com/learn/ion-sdk/ref-doc/Terrain.html

    // Catch errors from terrain provider to prevent Cesium from crashing with that annoying "rectangles" error
    terrain.readyEvent.addEventListener(provider => {
      provider.errorEvent.addEventListener(error => {
        console.log('intercepted tileProviderError at level: ', error.level);
        if (error.timesRetried < 5) {
          error.retry = true;
        } else {
          error.retry = false;
          console.error('Retries exhausted', error);
        }
      });
    });

The pattern is: I see my “Retries exhausted” error in the console, and then the app will crash if I zoom further at all. (without the limit of 5, it just entered an infinite loop of retries to no avail).

Anyone know a trick for getting around these errors?

Hi @bfreed,
Thanks for your post and for being a part of the Cesium community.

In order to better investigate and solve your problem, is it possible for you to provide a code example in our sandcastle tool https://sandcastle.cesium.com/ that recreates it? It is possible you are using an outdated bit of code from the API, but there is no way to know for sure without seeing some code. It appears the error is occuring when trying to load a tileset, so it may be helpful if you could also share with us information about what type of tileset you are loading into the scene. Starting an app in full globe view and zooming to a specific area is definitely not expected to throw this type of error.

Hope we can get this resolved soon.
Thanks,
Luke

Thanks for the response. Unfortunately (or fortunately?), I haven’t been able to make it happen in the sandcastle.
In my app, I’m trying to sync something else with the Cesium camera; it’s hard to mock up the external items in the sandcastle, but I tried some time-consuming functions to no avail.
My failures are here, FWIW: Sandcastle not breaking

I figured out that if I comment out the syncing code I was running, it doesn’t happen.
So I think that if I reorganize and don’t attach the sync listener until after I’ve zoomed in on a project, I may be able to avoid it.

I also see that sandcastle is using 1.130, whereas I’m on 1.129. I didn’t see anything like this in the changelog, but I’ll upgrade when I get a chance.
Today has gotten away from me and I need to set this bug to the side for a bit

Thanks @bfreed for your follow up. Sounds like the issue was related to the syncing code in your app and you were able to find a path forward on resolving the issue.

1.130 is the latest version of CesiumJS, but 1.129 is quite recent too. There are unlikely to be any changes affecting your app, but staying as up to date as possible is always a plus.

Please let us know if you have further questions and we would be happy to try and help further.

Thanks,
Luke