near / near-discovery

The homebase for Near Builders
https://dev.near.org
The Unlicense
49 stars 71 forks source link

Multiple inicializations of initVM #1264

Open gagdiez opened 2 months ago

gagdiez commented 2 months ago

Currently, the VM is re-initialized every single time the user changes pages. This is not only resource consuming, but also leads to weird errors where the components suddenly say "VM is dead" briefly before coming back to life.

This happens because the initNear is called each time the router.query changes:

https://github.com/near/near-discovery/blob/7f96c329e1c18c0970a6c6a39616708956f1e6a9/src/components/vm/VmInitializer.tsx#L177

I do not understand the code, but I think that we are trying to inject some URL parameters into link elements?

Ideally, we would use initNear only once, since it is for initializing the VM, and figure out a different way to handle the URL params