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

feat: spec compliant early hints #5

Merged
merged 20 commits into from Oct 6, 2022
Merged

feat: spec compliant early hints #5

merged 20 commits into from Oct 6, 2022

Conversation

climba03003
Copy link
Member

@climba03003 climba03003 commented Sep 29, 2022

Here is the implementation that should fit the spec.

  1. We should not restrict to only Link header
  2. We do not care about the result of Early Hints
  3. Use undici to test

In this PR, I provide two function which is writeEarlyHints and writeEarlyHintsLink
writeEarlyHints can be used to write any header.
writeEarlyHintsLink is used to write Link header like previous version.

Checklist

Copy link
Member Author

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

Do anyone have time to see why tap is not proceed to next test in node@14 and node@16?

@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 29, 2022

It seems that teardown is not called when the tests are finished because they still run because undici is still connected or so. So you have to explicitly close the client

@climba03003
Copy link
Member Author

climba03003 commented Sep 29, 2022

It seems that teardown is not called when the tests are finished because they still run because undici is still connected or so. So you have to explicitly close the client

Strange enough, I though it would be keepAliveTimeout issue and use setGlobalDispatcher. It doesn't work and it is actually the keepAliveTimeout issue which require to set in every Client.

No Idea, why undici test do not face the same problem.

README.md Outdated Show resolved Hide resolved
@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 29, 2022

I have just two remarks:

  1. I would like it more to call it writeEarlyHintsLinks. Or else people may think you can only pass one Link to that method. I actually think we should also add a segment regarding browser implementations and hint that google chrome uses only the first occurence of 103 and link to the chrome documentation. So maybe rename it to indicate it can handle multiple calls
  2. If I do autocannon against the example, i get crazy high number of request/s and a very low number of 103 statuscodes. If I use curl while running autocannon i get always 103. So I think that it is working properly. But I have some doubts... it is so confusing...

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

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 29, 2022

Strange. in node 14 we never get socket === null?

Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

LGTM

index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
test/writeEarlyHintsLinks.test.js Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 29, 2022

I patched and pushed example.js to run my tests

@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 29, 2022

I opened an issue in autocannon regarding the wrong stats I get from early hints
mcollina/autocannon#464

I actually would have loved to have a stress test, where i would expect 50% 103 and 50% 200 status to have the confidence that it works properly.

But my manual testing was successful so I am confident that this plugin is working reliable.

@Eomm
Copy link
Member

Eomm commented Oct 1, 2022

I would merge it and we could wait a sec before realising it.

Is ok for you @Uzlopak ?

@Uzlopak
Copy link
Contributor

Uzlopak commented Oct 6, 2022

@Eomm

Of course ;)

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

@mcollina mcollina merged commit 1f7df39 into master Oct 6, 2022
@SimenB SimenB deleted the spec-compliant branch October 6, 2022 15:43
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.

None yet

6 participants