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

fix(websockets): Prevent HTTP server early close in Socket.IO shutdown #14185

Merged

Conversation

sapenlei
Copy link
Contributor

@sapenlei sapenlei commented Nov 21, 2024

fixes #13910

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #13910

What is the new behavior?

When ws connections and other long-running connections are handled by the same HTTP server instance, the shutdown process will not be blocked, allowing for proper termination of all connection types.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Nov 21, 2024

Pull Request Test Coverage Report for Build 1f935bcf-2e20-49d2-8b77-6a4688c12cf5

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.989%

Totals Coverage Status
Change from base Build 118b06bc-2db5-429c-9b45-ae989ad7db1e: 0.0%
Covered Lines: 6809
Relevant Lines: 7402

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

LGTM

@@ -35,6 +40,9 @@ export abstract class AbstractWsAdapter<
}

public async close(server: TServer) {
if (this._forceCloseConnections) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

@sapenlei I just realized that this method should be called no matter the _forceCloseConnections for non-shared WS servers. This doesn't seem to be the case atm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even for non-shared ws servers, their connections are destroyed and the final shutdown is closed by express

Copy link
Member

Choose a reason for hiding this comment

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

How come? What if you use a port different from the HTTP application?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, there's a problem. I'll fix it tomorrow

Copy link
Contributor Author

@sapenlei sapenlei Nov 26, 2024

Choose a reason for hiding this comment

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

@kamilmysliwiec I fixed it #14204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Socket.IO Adapter Close causes premature HTTP Server close() call and blocks application shutdown
3 participants