Skip to content

Commit 28573b6

Browse files
cleanup and test
1 parent 28eff92 commit 28573b6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

lib/manager.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,18 @@ export class Manager<
473473
/**
474474
* Called upon a socket close.
475475
*
476-
* @param socket
476+
* @param nsp - the namespace of the socket being closed
477477
* @private
478478
*/
479-
_destroy(closingSocket: Socket): void {
480-
delete this.nsps[closingSocket.nsp];
479+
_destroy(nsp: string): void {
480+
delete this.nsps[nsp];
481+
481482
const nsps = Object.keys(this.nsps);
482483

483484
for (const nsp of nsps) {
484-
const socket = this.nsps[nsp];
485+
const remainingSocket = this.nsps[nsp];
485486

486-
if (socket.active) {
487+
if (remainingSocket.active) {
487488
debug("socket %s is still active, skipping close", nsp);
488489
return;
489490
}

lib/socket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ export class Socket<
881881
this.subs.forEach((subDestroy) => subDestroy());
882882
this.subs = undefined;
883883
}
884-
this.io["_destroy"](this);
884+
this.io._destroy(this.nsp);
885885
}
886886

887887
/**

test/connection.ts

+13
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ describe("connection", () => {
6060
s2.disconnect();
6161
});
6262

63+
it("should start a single connection with different namespaces (after disconnection)", () => {
64+
const s1 = io("/foo");
65+
const s2 = io("/bar");
66+
67+
s2.disconnect();
68+
69+
const s3 = io("/bar");
70+
71+
expect(s3.io).to.be(s1.io);
72+
s1.disconnect();
73+
s3.disconnect();
74+
});
75+
6376
it("should work with acks", () => {
6477
return wrap((done) => {
6578
const socket = io(BASE_URL, { forceNew: true });

0 commit comments

Comments
 (0)