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

WebsocketProvider disconnect method doesn't close the connection when provider is trying to reconnect #2882

@PierreJeanjacquot

Description

@PierreJeanjacquot

Description

WebsocketProvider disconnect method doesn't close the connection when provider is trying to reconnect

Expected behavior

Calling provider.disconnect() should always terminate the websocket connection.

Actual behavior

Calling provider.disconnect() doesn't terminate the websocket connection when the provider is trying to reconnect.

Steps to reproduce the behavior

  1. run a local node with websocket

  2. run the following code with Nodejs

const Web3 = require('web3');
const provider = new Web3.providers.WebsocketProvider('ws://localhost:8546');
provider.on('connect', () => console.log('connect'));
provider.on('error', () => {
  console.log('error');
  provider.disconnect();
});
provider.on('close', () => {
  console.log('close');
});

process logs:

connect
  1. Turn off you the local ethereum node
    process logs:
connect
error

the process should log close and exit as provider.disconnect() has been called.

Versions

  • web3.js: 1.0.0-beta.55
  • nodejs: v12.3.1

Note

Also tested with current code including #2711 correction:

# start nodejs
connect
# shutdown eth node
error
error
...
error
# restart eth node
connect

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.x2.0 related issuesBugAddressing a bugStaleHas not received enough activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions