Anyone seen InvalidStateError: View transition was skipped because document visibility state is hidden with Anvil Router?

Hi all,

I’m using the routing module in my app, and in the session logs I sometimes see this error for some users:

Browser session from null

**router**(/): navigating
: InvalidStateError: View transition was skipped because document visibility state is hidden.
**router**(/): navigate called with: None path='/login'
**router**(/): navigate location: /login
**router**(/login): navigating
**router**(/login): Match key /login:{}
**router**(/login): loading data for /login:{}
**router**(/login): /login:{} data not in cache
**router**(/login): data loaded: /login:{}

Not sure if the error is visible for the user.

I wasn’t able to reproduce this.

We’ve added some guards against this error, if you bump your version to 0.4.1

Hi Stuart,

Thanks for the tip. I have set the latest version now.

I see now that there is a new line “Failed to import routes module, ModuleNotFoundError(“No module named ‘routes’”)”. I have not seen before. Does not seem to affect anything. The app runs fine. But does not quite make sense.

router(/): Automatically importing routes module: ‘routes’
router(/): Failed to import routes module, ModuleNotFoundError(“No module named ‘routes’”) router(/): navigating
router(/): Match key /:{}
router(/): loading data for /:{}
router(/): /:{} data not in cache
router(/): data loaded: /:{}

router(): Failed to import routes module, ModuleNotFoundError(“No module named ‘M3_Routing.routes’”)
router(): Automatically importing routes module: ‘routes’

yes that’s expected - in the latest version you don’t actually need to import the routes module directly
You just need to tell the routing dependency which module to import and it will do it automatically when you call router.launch

If you’ve not set this in the config options for the routing dependency, then routing will assume the routes are defined in a module called routes

see docs on setting config options:
https://routing-docs.anvil.works/api-reference/#router-configuration

You should only see this message on the initial navigation.

1 Like

Tried it out and it works perfectly. Thanks for the quick response and help!

1 Like