If network gone, RPC is down, or something like that happen. then what would happen with the subscribe events of web3 js or python. do we need some additional codes to handle crash or subscribe event will do it automatically. code reference: https://web3js.readthedocs.io/en/v1.2.7/web3-eth-subscribe.html#id7

1 Answer 1


Ideally you would want to take care of any error handling if the event emitter returned from the subscription emits the "error" event.

From the documentation:

EventEmitter: An subscription instance as an event emitter with the following events:

"data" returns String: Fires on each incoming pending transaction and returns the transaction hash.
"error" returns Object: Fires when an error in the subscription occurs.

var subscription = web3.eth.subscribe('pendingTransactions', function(error, result){
    if (!error)
.on("data", function(transaction){
.on("error", () => {
    //handle error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.