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

Improve timeout handling for the block polling for confirmation #4527

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,7 @@ Released with 1.0.0-beta.37 code base.
## [Unreleased]

## [1.6.2]

### Changed

- Correct `web3.rst` example in documentation (#4511)
2 changes: 1 addition & 1 deletion docs/web3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The Web3 class is an umbrella package to house all Ethereum related modules.

var Web3 = require('web3');

// "Web3.providers.givenProvider" will be set if in an Ethereum supported browser.
// "Web3.givenProvider" will be set if in an Ethereum supported browser.
var web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546');

> web3.eth
Expand Down
4 changes: 3 additions & 1 deletion packages/web3-core-method/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
timeoutCount = 0,
confirmationCount = 0,
intervalId = null,
blockHeaderTimeoutId = null,
lastBlock = null,
receiptJSON = '',
gasProvided = ((!!payload.params[0] && typeof payload.params[0] === 'object') && payload.params[0].gas) ? payload.params[0].gas : null,
Expand Down Expand Up @@ -273,6 +274,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
sub = {
unsubscribe: function () {
clearInterval(intervalId);
clearTimeout(blockHeaderTimeoutId);
}
};
}
Expand Down Expand Up @@ -572,7 +574,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
});

// Fallback to polling if tx receipt didn't arrived in "blockHeaderTimeout" [10 seconds]
setTimeout(() => {
blockHeaderTimeoutId = setTimeout(() => {
if(!blockHeaderArrived) {
startInterval();
}
Expand Down