Is it a bug or a deliberate change ?
This is a... bug
I was not aware that we had reloading as a feature before. If it was, I'm personally against it since forced reload of pages may cause users to lose information they had on the dapp.
Also, what if someone changes network on a webpage that's not a dapp? Could cause more grief than convenience.
The classic behavior, @Zanibas is that we reloaded apps that had accessed the web3 variable.
You can see how we use ensnare to note when web3 has been accessed here:
https://github.com/MetaMask/metamask-plugin/blob/626903e9f237163fe00132c777435caa845ad3f3/app/scripts/lib/auto-reload.js
When an application has accessed the web3 object, we have to assume:
That means that when we change network, any dapp that has accessed web3 may have cached state that is now invalid. There is currently no event we emit to notify dapps about this (as web3 has no such event to emit), so a hard reload is currently the only way we can communicate network change to dapps, and Dapps simply need to be aware that they can be reloaded on network change, and store any state they need to persist in localStorage, for example.
It would be better to add an event to web3 to allow dapps to manage their own states, but even still, a dapp might prefer a hard reload, since the entirety of its state may be invalidated, it may be easier to simply start over, so even if we add a network change event, we might want to leave an option to let dapps get reloaded on network change.
seems like
metamaskStream.once('_data', function () {
pingStream.pipe(pingChannel).pipe(pingStream);
});
is never being triggered
seems like the event should be 'data' for the readable-stream implementation we are using
well, that's a simple solution.
yeah a little too simple... I remember doing it before and it caused problems...
@flyswatter We fixed slow-loading dapps by accidently breaking refresh https://github.com/MetaMask/metamask-plugin/commit/cc23158bfee2b723e8e80e0d25cbca2c2c6406a3
https://github.com/MetaMask/metamask-plugin/issues/746
https://github.com/MetaMask/metamask-plugin/pull/748
I guess I don't have a good way to QA this

disabling this fix to resolve this https://github.com/MetaMask/metamask-plugin/issues/746
bleh -- will be fixed after the holidays
Hard reload is a good default behavior, but a Dapp should be given the ability to prevent this behavior if it knows how to update its internal state. The Dapp should be allowed to be implement "network change" awareness via an event or polling web3.version.getNetwork()
Currently @frankiebee is working on allowing network switching without hard-reloading the background, this will allow for us to emit an event to update the network without reloading the page, and allow pages to opt to reload themselves if they like.
Great!
Is this closed now @frankiebee?
Oh sorry no, this needs to be accelerated to help the experience of fixing #247.
Fixed in PR #1496
Most helpful comment
Currently @frankiebee is working on allowing network switching without hard-reloading the background, this will allow for us to emit an event to update the network without reloading the page, and allow pages to opt to reload themselves if they like.