Skip to content

Clean up namespaces after client is rejected in middleware - #4773

Merged
darrachequesne merged 3 commits into
socketio:mainfrom
carera:cleanup-ns-on-mw-error
Jul 21, 2023
Merged

Clean up namespaces after client is rejected in middleware#4773
darrachequesne merged 3 commits into
socketio:mainfrom
carera:cleanup-ns-on-mw-error

Conversation

@carera

@carera carera commented Jul 19, 2023

Copy link
Copy Markdown
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Change is fixing bug described here: #4772

Comment thread lib/socket.ts
@@ -758,9 +758,6 @@ export class Socket<
}

this._cleanup();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_cleanup is called here and in two more places: https://github.com/socketio/socket.io/blob/main/lib/namespace.ts#L327-L333

I believe the this.nsp._remove(this); should be called in all these cases

Comment thread lib/socket.ts Outdated
this.leaveAll();
this.nsp._remove(this);
this.client._remove(this);
this.connected = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this.client._remove(this); and this.connected = false; are needed here, since the socket is not actually connected if it's rejected by the middleware. What do you think?

@carera carera Jul 20, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I just thought it does no harm since client._remove has a guard check and no-ops if the socket is not actually connected, but yeah, let me move it out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@darrachequesne
darrachequesne merged commit 0731c0d into socketio:main Jul 21, 2023
@darrachequesne

Copy link
Copy Markdown
Member

Thanks a lot 👍

@carera

carera commented Jul 21, 2023

Copy link
Copy Markdown
Contributor Author

Thank you for merging. What's the release process of this repo? Do I need to do something for this to roll out?

@darrachequesne

Copy link
Copy Markdown
Member

@carera we have a few other bug fixes in progress, I'll keep you updated.

@darrachequesne

Copy link
Copy Markdown
Member

Update: released in version 4.7.2 🚀

@darrachequesne darrachequesne added this to the 4.7.2 milestone Aug 3, 2023
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

Successfully merging this pull request may close these issues.

3 participants