web3/web3.js

timeout is not working with providers

开放

#6,178 创建于 2023年6月9日

 (18 条评论) (0 个反应) (1 位负责人)TypeScript (5,078 个派生)batch import
4.xBugDiscussionGood First Issue

仓库指标

星标
 (18,202 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南