HashRouting - cannot read getItem of undefined

I searched the forums for a routing solution and this looks really promising (thanks stucork!), but when I clone and run the HashRouting demo/example code (with the dependency library), the first thing I get after clicking around is the the following error:

ExternalError: TypeError: Cannot read property 'getItem' of null at 
app/HashRouting/routing.py, line 391 column 4 called from [Home, line 22]

It feels a little intimidating when I can’t even get the example demo to run properly. Can anyone help point me in the right direction on how to get this working properly so that I can look further into how it works? I’ve checked that the HashRouting library is set as a dependency in the example code.

I’m not sure what’s happening. I just cloned the example and it worked fine. I was able to run the example and navigate to different forms.

This is the clone link I used from the hash routing post, on the off chance there’s a different clone link somewhere: https://anvil.works/build#clone:ZKNOF5FRVLPVF4BI=JHFO3AIV2GTM5ZP4FPFL3SMI

Your error message is pointing to client-side code, so it shouldn’t depend on any particular server runtime or Anvil plan difference.

1 Like

I deleted all previous versions and clicked on your link above. The only thing I changed was the Servermodule1 setting from “Full Python 3” to “Basic Python 3.” Then I ran the app and clicked on Articles and then Blog Posts. Here’s a screenshot of what I get:

Do you know if this routing doesn’t work with Basic Python 3? I would assume if it relies on some paid libraries, it would just prompt me to upgrade instead of produce an error like this.

I can confirm that the example does work on free plans with the Basic Python 3 server runtime. I just loaded it into an alternate email that only has free access, and it worked fine.

I’m mystified by whatever is happening on your end. Maybe @stucork has ideas?

I’ll send a private message There might be a bit of back and forth here. I have a feeling it could be browser specific. It’s a very JavaScript looking error.

We found the cause - it was Brave Browser.
It is only a problem when running the app in the ide (and not a problem when running the app live)

The problem is likely because Brave can have higher security than other browsers and HashRouting uses window.sessionStorage (in order to store navigation)

However when running the app inside the IDE - the app is inside an iframe and so I can see why Brave might not allow an iframe to have access to window.sessionStorage

To fix the issue in brave we had to turn the brave shields down for anvil.works

2 Likes

For what it’s worth, further experimentation show incognito mode in Chrome has a similar error about not being able to access window.sessionStorage when running in the IDE.

1 Like