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

[v5] Failed to meet quorum when importing from @ethersproject/providers directly #874

Closed
Mrtenz opened this issue Jun 9, 2020 · 11 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@Mrtenz
Copy link

Mrtenz commented Jun 9, 2020

When trying to use any Provider method, it seems that importing from @ethersproject/providers doesn't work, wheres importing from ethers works fine. I'd prefer to import from @ethersproject/providers, since I don't need all of the functionality provided by ethers.

I am able to reproduce the issue with this code:

// This works fine
import { getDefaultProvider } from 'ethers';

const provider = getDefaultProvider();
    provider.getBalance('0x0000000000000000000000000000000000000000')
      .then(console.log)
      .catch(console.error);
// This doesn't work
import { getDefaultProvider } from '@ethersproject/providers';

const provider = getDefaultProvider();
    provider.getBalance('0x0000000000000000000000000000000000000000')
      .then(console.log)
      .catch(console.error);

The second one results in a long error:

failed to meet quorum (method="getBlockNumber", params={}, results=[{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"},"_nextId":43,"apiKey":"84842078b09946638c03157f83405213","projectId":"84842078b09946638c03157f83405213","projectSecret":null,"_internalBlockNumber":{}},"weight":1,"start":1591739065845,"error":{"reason":"missing response","code":"SERVER_ERROR","serverError":{},"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"}},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://eth-mainnet.alchemyapi.io/jsonrpc/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"},"_nextId":43,"apiKey":"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC","_internalBlockNumber":{}},"weight":1,"start":1591739065845,"error":{"reason":"missing response","code":"SERVER_ERROR","serverError":{},"url":"https://eth-mainnet.alchemyapi.io/jsonrpc/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"}},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"baseUrl":"https://api.etherscan.io","apiKey":"9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB","_internalBlockNumber":{}},"weight":1,"start":1591739066595,"error":{"reason":"missing response","code":"SERVER_ERROR","serverError":{},"url":"https://api.etherscan.io/api?module=proxy&action=eth_blockNumber&apikey=9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"}},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://cloudflare-eth.com/"},"_nextId":43,"_internalBlockNumber":{}},"weight":1,"start":1591739066595,"error":{"reason":"missing response","code":"SERVER_ERROR","serverError":{},"url":"https://cloudflare-eth.com/"}}], provider={"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"providerConfigs":[{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"},"_nextId":43,"apiKey":"84842078b09946638c03157f83405213","projectId":"84842078b09946638c03157f83405213","projectSecret":null,"_internalBlockNumber":{}},"weight":1,"stallTimeout":750,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"baseUrl":"https://api.etherscan.io","apiKey":"9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB","_internalBlockNumber":{}},"weight":1,"stallTimeout":750,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://eth-mainnet.alchemyapi.io/jsonrpc/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"},"_nextId":43,"apiKey":"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC","_internalBlockNumber":{}},"weight":1,"stallTimeout":750,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"connection":{"url":"https://cloudflare-eth.com/"},"_nextId":43,"_internalBlockNumber":{}},"weight":1,"stallTimeout":750,"priority":1}],"quorum":2,"_highestBlockNumber":-1,"_internalBlockNumber":{}}, code=SERVER_ERROR, version=providers/5.0.0-beta.171)

Here is a minimal repo where I'm able to reproduce this issue: https://github.com/Mrtenz/ethers.js-issue.

@zemse
Copy link
Collaborator

zemse commented Jun 9, 2020

There was a similar discussion recently: check this. A common factor in both issues is that, a blunder is involved. However, in my project (typescript/nodejs) the second snippet code works. Can this be an issue from the bundler? If someone can try reproducing with a different bundler.

@Mrtenz
Copy link
Author

Mrtenz commented Jun 9, 2020

Here's a version with a minimal Webpack configuration, no TypeScript, Babel or other stuff. I'm still able to reproduce, it seems like an incompatiblity with Ethers.js and browsers?

@Mrtenz
Copy link
Author

Mrtenz commented Jun 9, 2020

When using a JsonRpcProvider with a custom Ethereum node, it just fails with

Error: could not detect network (code=NETWORK_ERROR, version=providers/5.0.0-beta.171)

But no HTTP request is made at all...

@ricmoo
Copy link
Member

ricmoo commented Jun 9, 2020

I generally avoid running arbitrary repos on my computer. Can you include the output for dist/ in the repo?

Also, it looks like your web pack config may be missing the mainFields? Can you try adding "browser" to [the resolve.mainFields?

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Jun 9, 2020
@Mrtenz
Copy link
Author

Mrtenz commented Jun 9, 2020

I just pushed dist to the repo. Webpack should look for the browser field by default:

When the target property is set to webworker, web, or left unspecified:

webpack.config.js

module.exports = {
 //...
 resolve: {
   mainFields: ['browser', 'module', 'main']
 }
};

@ricmoo
Copy link
Member

ricmoo commented Jun 10, 2020

One more quick ask to help me debug... Can you include a non-minified version? :)

I see... Yes, I missed that "unspecified" part...

@Mrtenz
Copy link
Author

Mrtenz commented Jun 10, 2020

Just pushed a non-minified version. Thanks for looking into this!

@ricmoo
Copy link
Member

ricmoo commented Jun 12, 2020

Can you try out 5.0.0-beta.192 and let me know if that resolves the issue with react?

Thanks! :)

@ricmoo ricmoo added enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. and removed discussion Questions, feedback and general information. labels Jun 12, 2020
@Mrtenz
Copy link
Author

Mrtenz commented Jun 12, 2020

It's working now. thanks again 👍

@ricmoo
Copy link
Member

ricmoo commented Jun 14, 2020

I apparently posted a comment meant for this issue into the wrong tab. This was meant for this issue.

Not that it matters much. but might be useful in the future to keep things cross-referenced. :)

@TheKnightCoder
Copy link

For those that are still having problems after the patch. Try switch from esm to cjs. I was having the same problems in Aws lambda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

4 participants