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: invalid host message is missing on clientwith https (#3997) #3998

Merged
merged 1 commit into from Nov 13, 2021

Conversation

driskell
Copy link
Contributor

@driskell driskell commented Nov 1, 2021

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Added a new test that successfully fails with client.terminate

Motivation / Use-Case

See #3997. When host/origin headers do not match, client.terminate was being called. However, when HTTPS is enabled, this message is encrypted asynchronously by NodeJS before it gets written to the socket. Therefore, when client.terminate destroys the underlying socket the previous sendMessage had not yet been written to the socket.

Only applies when HTTPS is enabled.

Using client.close ensures that the socket is closed after all data is sent.

Breaking Changes

None

Additional Info

Granted, with a bad client, this could leak forever as there is no timeout. However, I do not see timeouts elsewhere so they could be added as part of adding them elsewhere. It's also a development tool that is unlikely to be very long lived, and will be extremely easy to restart upon any issue (always attended), so it's likely timeouts would unnecessarily overcomplicate the implementation with little benefit.

I also fixed loads of warnings I was getting running tests about EventEmitter leaks due to the signal listener that is registered when creating an instance. I can remove this code from this commit if it's a problem - it seemed very minor and fine to add as part of same commit - and either omit it entirely or raise separately for you.

Fixes #3997

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 1, 2021

CLA Signed

The committers are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #3998 (c280fbe) into master (6d060ed) will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3998      +/-   ##
==========================================
+ Coverage   92.60%   92.69%   +0.09%     
==========================================
  Files          14       14              
  Lines        1406     1410       +4     
  Branches      516      519       +3     
==========================================
+ Hits         1302     1307       +5     
+ Misses         96       95       -1     
  Partials        8        8              
Impacted Files Coverage Δ
lib/Server.js 93.93% <ø> (-0.07%) ⬇️
client-src/index.js 77.98% <0.00%> (-0.21%) ⬇️
lib/servers/WebsocketServer.js 97.14% <0.00%> (+5.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d060ed...c280fbe. Read the comment docs.

snitin315
snitin315 previously approved these changes Nov 2, 2021
Copy link
Member

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

Thanks

rishabh3112
rishabh3112 previously approved these changes Nov 7, 2021
setupTest.js Outdated Show resolved Hide resolved
@alexander-akait alexander-akait merged commit ff0869c into webpack:master Nov 13, 2021
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.

HTTPS clients do not receive Invalid Host/Origin header errors, they just get disconnected with no data
4 participants