Afterplot method triggers twice when opening cached forms

I am noticing a weird behavior where the afterplot method of a Plot component sometimes triggers twice when opening a form cached with anvil_extra’s hash-based routing.

Running routing.set_url_hash with load_from_cache=False fixed the problem so I have been able to identify the caching as causing this behaviour.

Moreover, this occurs most of the time but not all of the time (e.g., in 9/10 opens of a cached form).

I’ve been unable to determine why this happens. Is there anyone with better knowledge of the anvil_extras.routing module or plots who is able to give me some pointers as to what to look into? I would like to prevent the afterplot method from firing twice while still using the caching.

I tried a minimal example, but couldn’t reproduce.
Are you able to create one?