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: reset socket on GET & HEAD with body #250

Merged
merged 1 commit into from
Jul 11, 2020
Merged

fix: reset socket on GET & HEAD with body #250

merged 1 commit into from
Jul 11, 2020

Conversation

ronag
Copy link
Member

@ronag ronag commented Jul 11, 2020

Fixes: #246

@ronag ronag requested review from delvedor and mcollina July 11, 2020 09:05
@ronag ronag force-pushed the get-head-body branch 2 times, most recently from ad48105 to e59b4b9 Compare July 11, 2020 09:07
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

This probably should be written somewhere in the README as it's more strict compared to Node core.

@ronag
Copy link
Member Author

ronag commented Jul 11, 2020

@mcollina How strongly do you feel in regards to "semversiness" on this?

@mcollina
Copy link
Member

If we were crashing with GET and HEAD with a body before, it's a patch.

@ronag
Copy link
Member Author

ronag commented Jul 11, 2020

Added a "notes" section in the docs, documenting this.

@ronag
Copy link
Member Author

ronag commented Jul 11, 2020

@szmarczak

@szmarczak
Copy link
Member

I suggest adding an option to disable this. At Got we had bunch of issues complaining about this behavior.

Otherwise looks good :)

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

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

Is this happening only if pipelining is higher than 1? In such case we could allow sending a body if pipeline is 1 and throw it is higher than 1.
What do you think?

@szmarczak
Copy link
Member

szmarczak commented Jul 11, 2020

I agree, but that still doesn't fix the issue.

@ronag
Copy link
Member Author

ronag commented Jul 11, 2020

Is this happening only if pipelining is higher than 1?

It happens when the connection is re-used. Should probably clarify.

This might actually be a problem in Node core as well. Just harder to hit.

@ronag
Copy link
Member Author

ronag commented Jul 11, 2020

An alternative solution is to only send the request when nothing else is running, not send any further requests while it's running, and reconnect once the first response has been received.

@ronag ronag force-pushed the get-head-body branch 2 times, most recently from 6e42f53 to be8d06d Compare July 11, 2020 10:55
@ronag
Copy link
Member Author

ronag commented Jul 11, 2020

@delvedor @mcollina @szmarczak PTAL. I think this might be a better solution, i.e. don't allow any other running requests and reset the socket after the first response.

@ronag ronag requested review from mcollina and delvedor July 11, 2020 10:56
@ronag ronag force-pushed the master branch 3 times, most recently from 1efb8ae to 0ccbaff Compare July 11, 2020 11:39
@ronag ronag force-pushed the get-head-body branch 3 times, most recently from 9e646f0 to b16318f Compare July 11, 2020 11:44
@ronag ronag force-pushed the get-head-body branch 2 times, most recently from 8d4b2b1 to e25c9af Compare July 11, 2020 12:10
@ronag ronag force-pushed the master branch 8 times, most recently from 4f848c3 to 56d2829 Compare July 11, 2020 14:18
@ronag ronag changed the title fix: don't allow body on GET and HEAD fix: reset socket on GET & HEAD with body Jul 11, 2020
@ronag ronag force-pushed the get-head-body branch 2 times, most recently from 408ddd7 to ff3d53f Compare July 11, 2020 15:32
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@ronag ronag merged commit f6876d9 into master Jul 11, 2020
@szmarczak
Copy link
Member

Just a part of my comment from #258 (comment)

IMO, if it looks like a proper response, it should be parsed, and if the path doesn't match with the pipelined request (or there isn't any) then throw reconnect.

What about this?

@ronag
Copy link
Member Author

ronag commented Jul 14, 2020

if the path doesn't match with the pipelined request

I don't think responses contain the path? i.e. at least the http_parser does not provide it.

@szmarczak
Copy link
Member

If the data seems legit (looks like a HTTP/1.1 request), then you can check the path (url) here:

https://github.com/mcollina/undici/blob/e1990ce23c51a8b3fa4d4e18570f47467672ee28/lib/client-base.js#L370-L371

And if it doesn't match the pipelined request or there is none just simply reconnect.

@ronag
Copy link
Member Author

ronag commented Jul 15, 2020

If the data seems legit (looks like a HTTP/1.1 request), then you can check the path (url) here:

url is only set for requests, not responses

@szmarczak
Copy link
Member

Oooooh I was so confused for a while 😂 You're totally right. Pardon me.

@ronag ronag deleted the get-head-body branch April 25, 2021 22:20
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.

How to handle invalid server response?
4 participants