Web3.js: Websocket connection prevents node.js process from exiting

Created on 7 Aug 2018  路  10Comments  路  Source: ChainSafe/web3.js

After calling new Web3('ws://localhost:8545') the node.js process never ends but instead hangs forever
Calling web3.currentProvider.connection.close() does not help and throws error when using with the HttpProvider.
(Of course you can call process.exit(0) but it's ugly)

bug enhancement

Most helpful comment

So this issue relates to 1.0 branch then.

All 10 comments

Agreed. I suggest a method like:

web3.currentProvider.disconnect which just does nothing for the HTTPProvider.

Hi, I would like to start working on this issue. I'll assign it myself and submit a PR. Please suggest if that's not the process.

You can't assign it to your self but feel free to submit a PR and reference this issues there. @sawyna

@nivida I see the WebSocketProvider no longer exists on develop branch. . I could find it in the last beta though

https://github.com/ethereum/web3.js/tree/v1.0.0-beta.34/packages/web3-providers-ws

Also it was supported through Web3.providers.WebSocketProvider. It's no longer the case.
I tried looking at the code base to see if this got moved elsewhere with no luck. Can you shed some light on what happened?

@sawyna the develop branch is v20.x.x of Web3 and v1.0.0-beta.xx is in the 1.0 branch :)

So this issue relates to 1.0 branch then.

PR: #1881

There is no disconnect for ipc provider in https://github.com/ethereum/web3.js/pull/1881/files though. We would need one - a TODO.

Okay never mind. I have just done it - not a TODO anymore.

Oh yes! I missed it!

Was this page helpful?
0 / 5 - 0 ratings