Closed mitra42 closed 6 years ago
Do we want DwebTransports.p_connect({ });
just once ? Or do we want DwebTransports.p_connect({ });
to run as many times as a new URL is intercepted ?
Just once - your original version ran it multiple times; the current version runs once on loading; I'd like it to run once the FIRST time a URL is intercepted, but to be able to control that behavior via the flag I mentioned 2 comments above.
I get it
I notice this is worked on in current release. (please comment in Git when you work on things with a related issue). I notice three things. a) Equality tests should almost always be === not == (read up on the difference, its subtle) b) There are two tests ... it should work as currently written but I think:
if (!transportsLoaded)
because you always want a started transport in the listener. if (startTransportsAtLoad)
, as you only need to check if start is desired in the load-time test, it can't have been loaded already.
Combining these two things, I think this makes the desired code in the Listener. :
if (!transportsLoaded) {
p_connect({}).then(()->main(url, details, tabId));
} else {
main(url,details, tabId);
}
I have not tested this yet.
This would explain why I see "cat find any transport", main is trying to use the transports before they are loaded.
Yes you are right. p_connect() is asynchronous so that is why the error is popping up
@mitra42 please check out the latest commit. The fix you suggested worked. Thank you
Will do
I'm seeing it running twice on each load - Notice the line "resolving arc/archive.org" twice
That should not be happening. The flag transportsLoaded
is used to load Dwebtransports just once. You can see the line "Transports loaded 2 times" in the screenshot above. Looking into it.
Sorry, I'm talking about a different problem, I wasn't clear. I think p_connect is running only once. Its loading a page twice - even when the URL dweb.archive.org is pasted in
If you reload the extension and navigate to dweb.archive.org you will see that DwebTransports is loaded twice. And the URL is also captured twice. But if you then open a new tab and navigate to dweb.archive.org you will just see that the URL is captured twice. I think this has something to do with #28
Agreed = if I turn off the preload the problem goes away - I'll mark this as closed.
I'm currently starting transports in bootloader.js which I believe means when the extension is loaded, this starts IPFS and WebTorrent etc. That could slow things down even when not in the dweb, so I think we need. a) a flag in bootloader.js - "const startTransportsAtLoad = false" b) If that flag is set then start as now (last line of bootloader.js) c) If not set, then start the first time we intercept a matching URL.