opened
juharris
username_0
I found that with the current setup web3 wasn't being found in some cases with my app even though this one works fine. I think it's because of the mentioned race condition and the event listener for `"load"` wasn't getting triggered.

Sorry Node/JS isn't my main language please let me know if there are style issues and cases I didn't catch.
More robust getting web3.
issue
created
adrianmcli
username_1
Hi @username_0 thanks for the PR. Do you mind detailing to me, in an issue, what exactly is the problem? I would like to make sure I can replicate the bug first before incorporating any changes.
comment
created
juharris
username_0
I think it was because I had a bunch of setup logic in my constructor or stuff that needed to run before `getWeb3` was called. I probably could refactor but this won't be obvious to everyone so I thought that I should make `getWeb3` more robust to handle cases where the event listener for "load" would already be triggered.
comment
created
adrianmcli
username_1
I think this is a little out of scope for this project, but we are actually working on this in an upcoming tool. We take the path of checking `document.readyState` instead. You can have a look [here](https://github.com/trufflesuite/drizzle-utils/blob/master/packages/get-web3/index.js#L37-L40).

I thank you and appreciate the effort, but I think I will be closing this for now!
comment
created
juharris
username_0
Ah that solution looks much better.  Thanks for reviewing!
comment