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

Fix confirmation check after transaction getting stuck in a loop in some situations #4876

Closed
wants to merge 1 commit into from

Conversation

Darkhogg
Copy link

@Darkhogg Darkhogg commented Mar 21, 2022

Description

Sometimes, the checkConfirmation login became completely stuck and unable to exit properly, wasting a lot of CPU cycles and API calls on nothing.

I've seen this behaviour in situations where the generations of new blocks was slow (in which case polling kicks in and both polling and subscription remained working, but only one of them would ever finish) and when using .once('confirmation') on the result of a sendSignedTransaction call.

This PR fixes the afforementioned cases in the most simple way I came up with that doesn't break other stuff.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
    • Honestly, I have no idea how to test this, it doesn't produce any internally visible anything
  • I ran npm run test:unit with success.
  • I ran npm run test:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build and tested dist/web3.min.js in a browser.
  • I have tested my code on the live network.
    • On rinkeby, where I actually had the problem (and the problem is gone)
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.

Fix a bug that allows for a confirmation check to never end in some situations, such as when using .once('subscribe') and some other situations
@Darkhogg Darkhogg changed the title fix confirmation never finishing sometimes Fix confirmation check after transaction getting stuck in a loop in some situations Mar 21, 2022
@jdevcs jdevcs added the 1.x 1.0 related issues label Mar 21, 2022
@jdevcs jdevcs requested review from jdevcs, nazarhussain, spacesailor24 and avkos and removed request for nazarhussain March 21, 2022 20:14
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2017898581

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 429 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-2.3%) to 72.218%

Files with Coverage Reduction New Missed Lines %
packages/web3-core-requestmanager/src/jsonrpc.js 1 88.0%
packages/web3-core-helpers/src/formatters.js 25 81.07%
packages/web3-core-helpers/src/errors.js 31 4.41%
packages/web3-utils/src/soliditySha3.js 55 5.13%
packages/web3-utils/src/index.js 62 29.31%
packages/web3-utils/src/utils.js 92 12.86%
packages/web3-eth-accounts/src/index.js 163 23.77%
Totals Coverage Status
Change from base Build 2002669572: -2.3%
Covered Lines: 3368
Relevant Lines: 4396

💛 - Coveralls

@Darkhogg Darkhogg marked this pull request as draft March 21, 2022 21:13
@Darkhogg
Copy link
Author

Ok so apparently this also happens if you just... not subscribe to the confirmation event? I might spend some time tomorrow writing a proper set of test cases because I'm going insane right now.

@jdevcs
Copy link
Contributor

jdevcs commented Mar 30, 2022

Thanks @Darkhogg did you get time of adding test and fixing merge conflicts.

@jdevcs jdevcs added the In Progress Currently being worked on label Mar 30, 2022
@nazarhussain nazarhussain added the Review Needed Maintainer(s) need to review label Mar 31, 2022
Copy link
Contributor

@nazarhussain nazarhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Darkhogg Please convert the draft PR to ready and then request the request again.

@@ -306,7 +306,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) {
}

// check if confirmation listener exists
if (defer.eventEmitter.listeners('confirmation').length > 0) {
if (!canUnsubscribe || defer.eventEmitter.listeners('confirmation').length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending items are ( tests cases and fixing merge conflicts ). There is no activity on this PR from contributor so closing. @Darkhogg feel free to reopen and fix issues in this PR when have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues In Progress Currently being worked on Review Needed Maintainer(s) need to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants