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

http1 requests do not reuse sockets due to Connection: close header #33

Closed
pietermees opened this issue Feb 24, 2019 · 4 comments
Closed
Labels

Comments

@pietermees
Copy link

Node automatically sends Connection: close when not using an Agent:
https://github.com/nodejs/node/blob/master/lib/_http_client.js#L262

fetch-h2 disables the agent on http1 requests:

agent: false,

This means that http1 connections effectively are not reused at this time and every subsequent request creates a new Socket.

@grantila
Copy link
Owner

Right, I tried to build a test for this, but the default http server in Node.js doesn't close upon this header. This should be overrideable by the context, i.e. if you specify in the context options:

{
    http1: {
        keepAlive: true
    }
}

It currently defaults to false, I'm thinking of changing this to true, as that would likely make more sense.

@grantila
Copy link
Owner

I think that would fix it, but I'm unsure exactly how Node.js handles re-using connections or if fetch-h2 would have to explicitly have to set the Connection header perhaps, which would be sad.

@pietermees
Copy link
Author

pietermees commented Feb 27, 2019 via email

@grantila
Copy link
Owner

🎉 This issue has been resolved in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants