Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

timeout is not working with providers #6178

@hammersharkfish

Description

@hammersharkfish

Web3 provider timeout is getting ignored .
In my dapp I have set timeout to 5000 . web3.eth.getBlockNumber() doesn't throw even when public node takes more than 5s to respond .

Minimal example

var {Web3} = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("https://evm.confluxrpc.com", {timeout: 0 })); 
async function getNewBlock (){ 
    newBlock = await web3.eth.getBlockNumber();
    return newBlock
    
}
getNewBlock().then((nb)=>{ 
    console.log(" SHOULDN'T BE PRINTING THE BLOCK BUT IT IS: ",nb," block number")
})

Expected behavior

innerError: { code: -32000, message: 'failed after 0 retries: timeout' },

OUTPUT

SHOULDN'T BE PRINTING THE BLOCK BUT IT IS: 72889142n block number

Environment

Windows
Node.js v19.0.0.
web3 8.19.2

Metadata

Metadata

Assignees

Labels

4.x4.0 relatedBugAddressing a bugDiscussionGood First IssueGreat to learn the internals of web3.js

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions