[fixed] Sudden unhandled runtime errors for pwa offline behavior

What I’m trying to do:
Our apps are mission critical and thus rely heavily on the offline capability of anvil PWA’s.

We have seen strange errors when starting our pwa offline, after some digging this seems like.

We can’t reproduce it consistently and did a lot of digging.
Looking at the browser console the errors seem to be out of our control.


Basically my question, does this look like a framework bug or do we need to keep digging?

Mark

1 Like

We are experiencing the same error. Our logs show this info:

Did you have any luck narrowing this down to a root cause?
For us this only seems to occur when starting the app offline.
All our server / user calls are try-except wrapped

1 Like

Sadly not.

One ugly workaround we built is to set_default_error_handling → and then manually filter out runtime errors at the production environment.

But this is of course not a clean long term solution.

Hi folks,

This does indeed look like a bug at our end. We’re looking into it, and in the meantime @mark.breuss’s workaround is the best one, although I do know it’s ugly! Will update this thread as soon as we have more information for you.

[Moved to bug reports]

2 Likes

@daviesian Is there any update on this issue?

If not could you please expand on the workaround solution.

@apearce thanks for chasing - we think this particular bug might now be fixed - let us know if you’re still hitting it

3 Likes

@stucork thank you.

Yes, it appears to be fixed.

Could I ask what the issue was?

The short version is that the anvil internals were unnecessarily passing a Javascript error to the python error handler.

Javascript errors might show up as Unhandled runtime errors in the red indicator.
They’ll also get passed onto a custom error handler

Anvil Docs | Error Reporting

@mark.breuss can probably share the bit of the error handler that was helping to filter out these errors, my guess is it looked something like

import anvil
import anvil.js

def custom_error_handler(err):
    if isinstance(err, anvil.js.ExternalError):
        print(err) # ignore errors from javascript
    else:
        raise err # let the default error handler show it to the user

anvil.set_default_error_handling(custom_error_handler)
4 Likes