surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
271 stars 46 forks source link

Bug: When connecting multiple times there will be listeners stacking up each time #302

Open LucyEgan opened 3 days ago

LucyEgan commented 3 days ago

Describe the bug

Each time .connect(....) is called there will be another disconnected, error listener from it doing .disconnect() on the previous connection.

image

I'm pretty sure its related to this in ws.ts disconnect(

await Promise.any([
  this.requireStatus(ConnectionStatus.Disconnected),
  this.requireStatus(ConnectionStatus.Error),
]);

Steps to reproduce

db.connect() db.connect() db.connect() db.connect() db.connect()

Willl product the above example

Expected behaviour

the number of disconnected and error listeners to be cleaned up once complete.

SurrealDB version

2.0.0-alpha.4 for linux on x86_64

SurrealDB.js version

1.0.0-beta.12

Contact Details

lucy.e@aspirecomps.co.uk

Is there an existing issue for this?

Code of Conduct