Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError in JsonRpcProvider #822

Closed
wighawag opened this issue May 8, 2020 · 16 comments
Closed

ReferenceError in JsonRpcProvider #822

wighawag opened this issue May 8, 2020 · 16 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@wighawag
Copy link

wighawag commented May 8, 2020

Getting this error

 Uncaught (in promise) ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor

in

super(this.detectNetwork());

@ricmoo
Copy link
Member

ricmoo commented May 8, 2020

Did you remove your node_modules and lock files? I’ll look into this right away.

@ricmoo
Copy link
Member

ricmoo commented May 8, 2020

Actually... Weird, why am I not getting that compile time issue??

@ricmoo
Copy link
Member

ricmoo commented May 8, 2020

This is definitely a bug. And I'm concerned my TypeScript compiler isn't detecting it. What version are you using?

If I reorder the operations a bit, I can get my compiler to (correctly) complain.

@ricmoo
Copy link
Member

ricmoo commented May 8, 2020

I've got a fix in place, just testing now.

I've simplified the types JsonRpcProvider can accept as well. Previously you could do something like new JsonRpcProvider("homestead"), leaving the url empty and it would realize and use the default localhost url on homestead. Now you will need to pass null in as a first parameter to use the default.

This is not as important now, since the eth_chainId method is wide-spread. Historically there network detection was unreliable, but I would argue is actually the preferred method these days. ;)

@ricmoo ricmoo added bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. labels May 8, 2020
@ricmoo
Copy link
Member

ricmoo commented May 8, 2020

The CI has finally passed and this has been published to 5.0.0-beta.186. I've also bumped all the package.json versions in each package.json, so there should be no need to clear out node_modules, etc.

Try it out and let me know if there is still a problem.

I'm also still interested in reproducing the original issue locally. Can you pass along what version of TypeScript you were using? My version let that through without issue. Maybe there is a tsconfig setting (which would seem weird to allow wildly unsafe behaviour).

Thanks!

@wighawag
Copy link
Author

The issue was in the umd output of this lib : https://github.com/wighawag/svelte-wallet that use rollup to bundle the output in multiple format.

the umd output was then used in my application and got the error mentioned at runtime

@ricmoo
Copy link
Member

ricmoo commented May 11, 2020

Does the latest issue still have this problem?

I will also be opening a bug with TypeScript later (I've searched a bit but haven't found an already existing issue on their repo). I'll link to it here.

@wighawag
Copy link
Author

@wighawag
Copy link
Author

The latest seem to works fine

@ricmoo
Copy link
Member

ricmoo commented May 11, 2020

Awesome. Yeah, that line was in the older version. Glad it works now. :)

@wighawag
Copy link
Author

@ricmoo
Copy link
Member

ricmoo commented May 11, 2020

Ah yes... I think that will.

Thanks, I'll grep the source for all uses of super.

@ricmoo
Copy link
Member

ricmoo commented May 12, 2020

I've opened this bug on TypeScript. Let me know if there is anything else to add.

@ricmoo
Copy link
Member

ricmoo commented May 12, 2020

FYI. Looks like that issue has been marked to be fixed in TypeScript 4. :)

@ricmoo
Copy link
Member

ricmoo commented May 13, 2020

The FallbackProvider has also been updated and is available in 5.0.0-beta.187.

@ricmoo
Copy link
Member

ricmoo commented May 14, 2020

Closing this now, but if you have any more issues please re-open.

Thanks! :)

@ricmoo ricmoo closed this as completed May 14, 2020
michaeltout pushed a commit to michaeltout/ethers.js that referenced this issue Aug 23, 2020
michaeltout pushed a commit to michaeltout/ethers.js that referenced this issue Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants