I found a very similar issue like mine. But I cannot find the answer. So I posted a new issue here. Thanks for your help!
#ethers-io/ethers.js#841 (comment)
Part of my code below where @uniswap/sdk used ethers.js with @[email protected] :
require("dotenv").config();
const Web3 = require("web3");
const {
ChainId,
Token,
TokenAmount,
WETH,
Fetcher,
Trade,
} = require("@uniswap/sdk");
const abis = require("./abis");
const Web3WsProvider = require("web3-providers-ws");
const options = {
timeout: 30000, // ms
headers: {
authorization: "Basic username:password",
},
clientConfig: {
maxReceivedFrameSize: 100000000, // bytes - default: 1MiB
maxReceivedMessageSize: 100000000, // bytes - default: 8MiB
keepalive: true,
keepaliveInterval: 60000, // ms
},
reconnect: {
auto: true,
delay: 5000, // ms
maxAttempts: 5,
onTimeout: false,
},
};
const ws = new Web3WsProvider(
"wss://mainnet.infura.io/ws/v3/" + process.env.INFURA_URL_0,
options
);
const web3 = new Web3(ws);
const {address: admin} = web3.eth.accounts.wallet.add(process.env.PRIVATE_KEY);
const init = async () => {
await web3.eth
.subscribe("newBlockHeaders")
.on("data", async (block) => {
console.log(`New block received. Block # ${block.number}`);
const dai = new Token(
ChainId.MAINNET,
"0x6B175474E89094C44Da98b954EedeAC495271d0F",
18
);
const weth = WETH[dai.chainId];
const daiWeth_Pair = await Fetcher.fetchPairData(dai, weth);
const amountsEth = await Promise.all([
kyber.methods
.getExpectedRate(
addresses.tokens.dai,
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
AMOUNT_DAI_WEI
)
.call(), //! bug possible
daiWeth_Pair.getOutputAmount(new TokenAmount(dai, AMOUNT_DAI_WEI)),
]).catch(console.log);
}).on("error", (error) => {
console.log(error);
});
};
init();
Some Error information:
![image](https://user-images.githubusercontent.com/2143234/94225402-6c0fbe80-ff27-11ea-9679-5009001228fa.png)
Error1:
New block received. Block # 10929215
New block received. Block # 10929216
(node:73511) UnhandledPromiseRejectionWarning: Error: failed to meet quorum (method="call", params={"transaction":{"to":"0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11","data":"0x0902f1ac"},"blockTag":"latest"}, results=[{"weight":1,"start":1601002249658,"result":"0x0000000000000000000000000000000000000000008182938c6e045bed6d6efe00000000000000000000000000000000000000000000604b50e085a4069fac51000000000000000000000000000000000000000000000000000000005f6d5ad5"},{"weight":1,"start":1601002249658,"result":"0x00000000000000000000000000000000000000000081816a72defcb033330d3600000000000000000000000000000000000000000000604c65ac967fa3989342000000000000000000000000000000000000000000000000000000005f6d5b05"},{"weight":1,"start":1601002250409,"result":"0x00000000000000000000000000000000000000000081831f5143b902a9a8e50700000000000000000000000000000000000000000000604b1fdd41a7c07cdd37000000000000000000000000000000000000000000000000000000005f6d5b02"},{"weight":1,"start":1601002250410,"error":{"reason":"missing response","code":"SERVER_ERROR","requestBody":null,"requestMethod":"GET","serverError":{"errno":"ECONNRESET","code":"ECONNRESET","syscall":"read"},"url":"https://api.etherscan.io/api?module=proxy&action=eth_call&to=0xa478c2975ab1ea89e8196811f51a7b7ade33eb11&data=0x0902f1ac&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":10929215,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1601002249657,"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":10929215,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1601002249657,"connection":{"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"},"_nextId":44,"apiKey":"84842078b09946638c03157f83405213","projectId":"84842078b09946638c03157f83405213","projectSecret":null,"_internalBlockNumber":{},"_fastBlockNumber":10929215,"_fastBlockNumberPromise":{}},"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":10929215,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1601002251606,"connection":{"url":"https://eth-mainnet.alchemyapi.io/v2/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"},"_nextId":44,"apiKey":"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC","_internalBlockNumber":{},"_fastBlockNumber":10929215,"_fastBlockNumberPromise":{}},"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":10929213,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1601002248720,"connection":{"url":"https://cloudflare-eth.com/"},"_nextId":44,"_internalBlockNumber":{},"fastBlockNumber":10929213,"fastBlockNumberPromise":{}},"weight":1,"stallTimeout":750,"priority":1}],"quorum":2,"highestBlockNumber":10929215,"internalBlockNumber":{},"fastBlockNumber":10929215,"fastBlockNumberPromise":{}}, code=SERVER_ERROR, version=providers/5.0.9)
at Logger.makeError (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/logger/lib/index.js:179:21)
at Logger.throwError (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/logger/lib/index.js:188:20)
at FallbackProvider. (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:676:54)
at step (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:46:23)
at Object.f [as next] (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:27:53)
at fulfilled (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:18:58)
(node:73511) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:73511) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error2:
(node:73511) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 35)
(node:73511) UnhandledPromiseRejectionWarning: Error: failed to meet quorum (method="getBlockNumber", params={}, results=[{"weight":1,"start":1601003217919,"error":{"reason":"timeout","code":"TIMEOUT","requestBody":"{"method":"eth_getBlockByNumber","params":["latest",false],"id":42,"jsonrpc":"2.0"}","requestMethod":"POST","timeout":120000,"url":"https://cloudflare-eth.com/"}},{"weight":1,"start":1601003217920,"error":{"reason":"timeout","code":"TIMEOUT","requestBody":"{"method":"eth_blockNumber","params":[],"id":42,"jsonrpc":"2.0"}","requestMethod":"POST","timeout":120000,"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"}},{"weight":1,"start":1601003526002,"error":{"reason":"timeout","code":"TIMEOUT","requestBody":"{"method":"eth_blockNumber","params":[],"id":42,"jsonrpc":"2.0"}","requestMethod":"POST","timeout":120000,"url":"https://eth-mainnet.alchemyapi.io/v2/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"}},{"weight":1,"start":1601003526002,"error":{"reason":"timeout","code":"TIMEOUT","requestBody":null,"requestMethod":"GET","timeout":120000,"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,"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/v2/_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.9)
at Logger.makeError (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/logger/lib/index.js:179:21)
at Logger.throwError (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/logger/lib/index.js:188:20)
at FallbackProvider. (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:676:54)
at step (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:46:23)
at Object.f [as next] (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:27:53)
at fulfilled (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/providers/lib/fallback-provider.js:18:58)
Error3:
Exception has occurred: Error
Error: missing response (requestBody="{"method":"eth_call","params":[{"to":"0xa478c2975ab1ea89e8196811f51a7b7ade33eb11","data":"0x0902f1ac"},"latest"],"id":43,"jsonrpc":"2.0"}", requestMethod="POST", serverError={"errno":"ECONNRESET","code":"ECONNRESET","syscall":"read"}, url="https://eth-mainnet.alchemyapi.io/v2/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC", code=SERVER_ERROR, version=web/5.0.7)
at Logger.makeError (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/logger/lib/index.js:179:21)
at Logger.throwError (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/logger/lib/index.js:188:20)
at /Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/web/lib/index.js:211:36
at step (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/web/lib/index.js:33:23)
at Object.f [as throw] (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/web/lib/index.js:14:53)
at rejected (/Users/zheng/Security/bots/ArBot/node_modules/@[email protected]@@ethersproject/web/lib/index.js:6:65)
at process._tickCallback (internal/process/next_tick.js:68:7)