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

Commit 0e6da89

Browse files
nazarhussainhong4rcAlex
authoredNov 10, 2021
Improve timeout handling for the block polling for confirmation (#4527)
* 🎨 Improve the block header timeout handling * Update comment web3.rst (#4511) * Update comment web3.rst * updating changelog Co-authored-by: Alex <alex.luu@mail.utoronto.ca> Co-authored-by: Anh Hong <hong4rc@gmail.com> Co-authored-by: Alex <alex.luu@mail.utoronto.ca>
1 parent 144fbe4 commit 0e6da89

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,7 @@ Released with 1.0.0-beta.37 code base.
479479
## [Unreleased]
480480

481481
## [1.6.2]
482+
483+
### Changed
484+
485+
- Correct `web3.rst` example in documentation (#4511)

‎docs/web3.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The Web3 class is an umbrella package to house all Ethereum related modules.
6464
6565
var Web3 = require('web3');
6666
67-
// "Web3.providers.givenProvider" will be set if in an Ethereum supported browser.
67+
// "Web3.givenProvider" will be set if in an Ethereum supported browser.
6868
var web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546');
6969
7070
> web3.eth

‎packages/web3-core-method/src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
205205
timeoutCount = 0,
206206
confirmationCount = 0,
207207
intervalId = null,
208+
blockHeaderTimeoutId = null,
208209
lastBlock = null,
209210
receiptJSON = '',
210211
gasProvided = ((!!payload.params[0] && typeof payload.params[0] === 'object') && payload.params[0].gas) ? payload.params[0].gas : null,
@@ -273,6 +274,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
273274
sub = {
274275
unsubscribe: function () {
275276
clearInterval(intervalId);
277+
clearTimeout(blockHeaderTimeoutId);
276278
}
277279
};
278280
}
@@ -572,7 +574,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
572574
});
573575

574576
// Fallback to polling if tx receipt didn't arrived in "blockHeaderTimeout" [10 seconds]
575-
setTimeout(() => {
577+
blockHeaderTimeoutId = setTimeout(() => {
576578
if(!blockHeaderArrived) {
577579
startInterval();
578580
}

0 commit comments

Comments
 (0)
This repository has been archived.