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

[web3@1.0.0-beta.41] getPastEvents not working - {"code":-32603,"message":"request failed or timed out"} #2311

Closed
ironbyte opened this issue Feb 3, 2019 · 12 comments · Fixed by #2338
Labels
Bug Addressing a bug

Comments

@ironbyte
Copy link

ironbyte commented Feb 3, 2019

Expected behavior

Fetch all past events starting with a given block number

Actual behavior

It always return the following error:

Error: Node error: {"code":-32603,"message":"request failed or timed out"}

Downgrading back to web3@1.0.0-beta.37 fixes the issue.

Steps to reproduce the behavior

const httpProvider = new Web3.providers.HttpProvider(infuraHTTPProviderURL);
const web3Instance = new Web3(httpProvider);
const coreContractInstance = new web3Instance.eth.Contract(coreABI, coreContractAddress);

coreContractInstance.getPastEvents('Birth', { fromBlock: 3768892 })
  .then((pastBirthEvents) => { debug('pastBirthEvents: %O', pastBirthEvents) })
  .catch((error) => { debug('error: ', error); process.exit(1) });

Error Logs

(node:379) UnhandledPromiseRejectionWarning: Error: Node error: {"code":-32603,"message":"request failed or timed out"}
    at Function.validate (/home/****/projects/*********/crypto-kitty-midwife/node_modules/web3-providers/dist/web3-providers.cjs.js:66:18)
    at /home/****/projects/*********/crypto-kitty-midwife/node_modules/web3-providers/dist/web3-providers.cjs.js:128:57
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:379) 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:379) [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.

Versions

[NPM, Node, Web3.js, OS, device...]

web3@1.0.0-beta.41
node@v8.14.0
npm@6.5.0
OS: Linux/Ubuntu 18.04

@nivida nivida added the Bug Addressing a bug label Feb 4, 2019
@neocybereth
Copy link

same for me.

@neocybereth
Copy link

@ironbyte are you using an Infura node?

@ironbyte
Copy link
Author

ironbyte commented Feb 5, 2019

@Sm00g15 Yep, I use an Infura WSS endpoint (wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID)

@neocybereth
Copy link

@ironbyte same here. I also tried switching to an HTTP provider and no dice

@nivida nivida added the In Progress Currently being worked on label Feb 6, 2019
@nivida
Copy link
Contributor

nivida commented Feb 6, 2019

I've tested it with my local test-net and different providers and it works without a problem.
screenshot 2019-02-06 at 12 52 01

Could you please add the address of the deployed contract you are testing it?

@nivida nivida added more information needed and removed In Progress Currently being worked on labels Feb 6, 2019
@nivida
Copy link
Contributor

nivida commented Feb 6, 2019

The same error did just appear. This error does only appear if the infura node does take to long until it got all the past event logs or when it can't find past logs. I would recommend to configure the timeout time of the provider with the option properties you can pass to the provider.

@neocybereth
Copy link

@ironbyte any luck on your end?

@neocybereth
Copy link

neocybereth commented Feb 6, 2019

#2000 ; looks like this will fix it @nivida . Any idea when these changes will go live?

After updating the provider options I'm now hitting this error:

(node:37749) UnhandledPromiseRejectionWarning: Error: Connection error: Connection is not open on send()
    at /Users/smorgin099/projects/node_modules/web3-providers/dist/web3-providers.cjs.js:519:27

@mistersandman
Copy link

mistersandman commented Feb 6, 2019

The error indeed indicates that the node timed out when processing the request. However, the issue lies in the fact that with the recent library refactoring the contract address does not get added to the request parameters anymore! Thus, the events of all contracts on the chain will be queried, which is not hard to imagine to hit a timeout quickly 😃 Please reopen this issue.

@ironbyte
Copy link
Author

ironbyte commented Feb 7, 2019

@Sm00g15 Hey, I've already downgraded back to web3@1.0.0.beta-37. Everything works on this version on my end. I will try a different provider on beta 41 later today. Will report if anything interesting happens.

@neocybereth
Copy link

@ironbyte @mistersandman @nivida - based on @mistersandman 's comment above I've opened up a new issue here: #2337

@neocybereth
Copy link

neocybereth commented Feb 9, 2019

The error indeed indicates that the node timed out when processing the request. However, the issue lies in the fact that with the recent library refactoring the contract address does not get added to the request parameters anymore! Thus, the events of all contracts on the chain will be queried, which is not hard to imagine to hit a timeout quickly 😃 Please reopen this issue.

@mistersandman can we fix this by manually adding the contract address to the parameters? My site has been down for days from this issue

EDIT: This issue was resolved by upgrading my Infura node to the latest V3 REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@nivida @mistersandman @neocybereth @ironbyte and others