Ethers.js: ReferenceError in JsonRpcProvider

Created on 8 May 2020  路  16Comments  路  Source: ethers-io/ethers.js

Getting this error

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

in https://github.com/ethers-io/ethers.js/blob/7f0374c5a5ecb636d02f30fc9aa4f358e8fee7e9/packages/providers/src.ts/json-rpc-provider.ts#L238

bug fixed

Most helpful comment

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

All 16 comments

Did you remove your node_modules and lock files? I鈥檒l look into this right away.

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

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.

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. ;)

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!

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

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.

The latest seem to works fine

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

Ah yes... I think that will.

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

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

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

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

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

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lastmjs picture lastmjs  路  31Comments

pointtoken picture pointtoken  路  24Comments

Tomix3D picture Tomix3D  路  39Comments

ricmoo picture ricmoo  路  24Comments

cloudonshore picture cloudonshore  路  25Comments