You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a novice in etherium and blockchain, so I am making mistakes even writing a HelloWorld application.
Therefore, I made a mistake, missing an API key, when rewriting the code to use a new ethers.getDefaultProvider() method instead of disappeared ethers.providers collection to use v6.
When I tried to get a message property, I have got the following error (sometimes):
/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-etherscan.ts:370
if (message.match(/execution reverted/i)) {
^
TypeError: Cannot read properties of undefined (reading 'match')
at EtherscanProvider._checkError (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-etherscan.ts:370:25)
at EtherscanProvider._perform (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-etherscan.ts:499:33)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at EtherscanProvider.#call (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/abstract-provider.ts:953:29)
at async Promise.all (index 1)
at resolveProperties (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/utils/properties.ts:35:21)
at EtherscanProvider.#checkNetwork (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/abstract-provider.ts:1011:27)
at EtherscanProvider.call (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/abstract-provider.ts:1024:16)
at FallbackProvider._translatePerform (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-fallback.ts:444:24)
at /disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-fallback.ts:517:32
I looked to the provider-etherscan.ts code and found, that the message variable is used at the line 370 as well as at the line 362 to call match method before checking for existence at the line 382.
The problem probably happens when the message is initialized from inexistent properties of objects in the code above. Such initialization does not raise exception, and assigns undefined value to the message variable instead, even if the message had the (empty) string value before.
I checked my hypothese moving the line 382 to the line 360, just before the first block where it is used, and found an initial error (wrong API key) which was produced by my mistake.
/disk0/home/seva/OGOO/node_modules/ethers/src.ts/utils/errors.ts:694
error = new Error(message);
^
Error: invalid JSON-RPC response (missing jsonrpc='2.0') (request={ }, response={ }, info={ "result": { "message": "NOTOK", "result": "Invalid API Key", "status": "0" } }, code=SERVER_ERROR, version=6.8.1)
at makeError (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/utils/errors.ts:694:21)
at assert (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/utils/errors.ts:715:25)
at EtherscanProvider.fetch (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-etherscan.ts:283:23)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at EtherscanProvider._perform (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/provider-etherscan.ts:497:28)
at EtherscanProvider.#call (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/abstract-provider.ts:953:29)
at async Promise.all (index 1)
at resolveProperties (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/utils/properties.ts:35:21)
at EtherscanProvider.#checkNetwork (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/abstract-provider.ts:1011:27)
at EtherscanProvider.call (/disk0/home/seva/OGOO/node_modules/ethers/src.ts/providers/abstract-provider.ts:1024:16)
The problem does not appear every time, but appears sometimes (probably regarding to some caching).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
ethers.js v 6.8.1
I'm a novice in etherium and blockchain, so I am making mistakes even writing a HelloWorld application.
Therefore, I made a mistake, missing an API key, when rewriting the code to use a new
ethers.getDefaultProvider()
method instead of disappearedethers.providers
collection to use v6.When I tried to get a
message
property, I have got the following error (sometimes):I looked to the
provider-etherscan.ts
code and found, that themessage
variable is used at the line 370 as well as at the line 362 to callmatch
method before checking for existence at the line 382.The problem probably happens when the message is initialized from inexistent properties of objects in the code above. Such initialization does not raise exception, and assigns
undefined
value to themessage
variable instead, even if themessage
had the (empty) string value before.I checked my hypothese moving the line 382 to the line 360, just before the first block where it is used, and found an initial error (wrong API key) which was produced by my mistake.
The problem does not appear every time, but appears sometimes (probably regarding to some caching).
Please fix the problem.
Beta Was this translation helpful? Give feedback.
All reactions