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

Websocket reconnection failure with NodeJs 22.X #6079

Open
osan15 opened this issue Jan 27, 2025 · 0 comments
Open

Websocket reconnection failure with NodeJs 22.X #6079

osan15 opened this issue Jan 27, 2025 · 0 comments

Comments

@osan15
Copy link

osan15 commented Jan 27, 2025

There seems to be a problem with the automatic reconnection of the WebSocket client on the NodeJS 22 version.

const provider = new WsProvider('ws://127.0.0.1:9944');
const api = await ApiPromise.create({ provider });
api.on('disconnected', () => {
  console.log(`Disconnected`);
});
api.on('connected', () => {
  console.log(`Connected`);
});
api.on('error', (err) => {
  // When the API is disconnected, it will emit an error event

  console.error(err);
 // ErrorEvent {
 //   type: 'error',
 //   defaultPrevented: false,
 //   cancelable: false,
 //   timeStamp: 9766.533212
 //  }

console.error(err.message);
// Received network error or non-101 status code.
});

When I stop the blockchain node, I receive an error event in the “error” listener.
When the node is restarted, the WebSocket client is never reconnected.

Versions :

NodeJS version : 22.12
"@polkadot/api": "^15.1.1"

The same code downgraded to NodeJS version 20.18.2 does not trigger this issue.

I found similar issues with other packages :

Has anyone experienced this bug ?

Thanks for your answers

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

1 participant