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

sendSignedTransaction never close websocket connection [1.2] #3094

Closed
stefdelec opened this issue Oct 2, 2019 · 4 comments
Closed

sendSignedTransaction never close websocket connection [1.2] #3094

stefdelec opened this issue Oct 2, 2019 · 4 comments

Comments

@stefdelec
Copy link

stefdelec commented Oct 2, 2019

Description

When i call on sendSignedTransaction on nodejs, node process never ends because it seems that websocket connection is actually never closed.
It may lead to memory leak on server side.

Expected behavior

web3.eth.sendSignedTransaction(result.rawTransaction)
                    .on("confirmation", (confirmationNumber, receipt) => {
                        //do something
                    })

Expected behavior : To close websocketConnection, if I need only 'confirmation' event.

Actual behavior

Steps to reproduce the behavior

Launch nodejs process and see it never ends.

     web3.eth.sendSignedTransaction(result.rawTransaction)
                   .on("confirmation", (confirmationNumber, receipt) => {
                   // do something
                   })

   

Versions

  • web3.js: 1.2.1
  • nodejs: 10
@stefdelec stefdelec changed the title sendSignedTransaction never close websocket connection sendSignedTransaction never close websocket connection [1.2] Oct 2, 2019
@cgewecke
Copy link
Collaborator

cgewecke commented Oct 7, 2019

@stefdelec Hi. You might be looking for once instead of on. This will fire a single time on the first confirmation.

web3.eth.sendSignedTransaction(result.rawTransaction)
  .once("confirmation", (confirmationNumber, receipt) => {
     // do something
  })

In 1.2x, when you attach the confirmations handler using on, it will fire for 24 confirmations. To stop listening you have to remove the listener following the Node EventEmitter API.

Closing - the web3 docs are reasonably clear about how PromiEvents work & what they are.

@cgewecke cgewecke closed this as completed Oct 7, 2019
@stefdelec
Copy link
Author

Same behavior with once. It does not close the websocket.

@cgewecke
Copy link
Collaborator

cgewecke commented Oct 8, 2019

@stefdelec
Are you sure that the transaction is being mined? When you attach the receipt listener do you get a receipt?

If you're connecting to Ropsten could you look at #3104 and this comment to make sure that you're signing the transaction correctly for the Istanbul fork?

@nivida
Copy link
Contributor

nivida commented Oct 8, 2019

The websocket connection stays established for the whole time. Otherwise we would have to connect and disconnect on each request. The wished behavior would also force us to re-establish subscriptions all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants