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: do not abort when stream payload consumed #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simosho
Copy link

@simosho simosho commented Nov 22, 2024

addresses #62

@@ -93,7 +93,7 @@ module.exports = fp(
if (raw.socket.destroyed) {
throw new Errors.SOCKET_CLOSED(reqId)
} else {
raw.once(
raw.socket.once(
'close',
function () {
if (controllers.has(this)) {
Copy link
Author

Choose a reason for hiding this comment

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

I tried checking if the request was completed by doing

Suggested change
if (controllers.has(this)) {
if (!raw.completed && controllers.has(this)) {

but that doesn't seem to work as intended for a http1.1 client like unidici.

Do we need some other check, as i'm not sure if it will work for http2 clients, as they can close their sending side of the socket while keeping the receiving side open?

Copy link
Owner

Choose a reason for hiding this comment

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

This check is a must, otherwise we can abort the request as soon as the transmission has finished (request payload received and parsed).

A keep-alive connection is independent of a request lifecycle; the keep alive is handled by the socket while the request lifecycle by the IncomingMessage API (or HTTPServerRequest for HTTP/2).

Let's add it, I believe your tests already covers these cases. Maybe one more for HTTP/2 can be helpful

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.

Requests with multipart/form-data flagged as aborted immediately after payload consumed
2 participants