-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby-source-drupal): Disable caching + add http/2 agent #32012
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
83d2ae8
feat(gatsby-source-drupal): Force revalidation on Drupal API requests
KyleAMathews 5696194
Remove debugging line
KyleAMathews c0aa244
Add http/2 agent
KyleAMathews 4c9f64e
Disable cache — it's slower than refetch with revalidation
KyleAMathews 30737ea
push don't concat
KyleAMathews 00564c1
consistent return
KyleAMathews 282cbb5
Fix statusCode check for got
KyleAMathews 458687f
Actually this was correct...
KyleAMathews 5fbf618
Actually use http/2
KyleAMathews File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to pass
request: http2wrapper.auto
here, as Got v11 doesn't use the newest version ofhttp2-wrapper
. Got v12 is going to be released in the next few weeks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for weighing in @szmarczak !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I almost forgot. You need to set the
http2
option totrue
as well. It will pass the entireagent
object tohttp2wrapper
, otherwise it would passagent: httpsAgent
which results in an error if the endpoint is HTTP/2.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh haha thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fix it 5fbf618
Thanks btw for all your great work on Got! It's a fantastic piece of software.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random aside while we have you, I profiled this with http/2 & it looks like
normalizeArguments
is using more than its fair share of CPU?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem :) I really enjoy improving it.
https://github.com/sindresorhus/got/blob/f896aa52abc41fe40d4942da94a0408477358f14/source/core/index.ts#L2364-L2367
This hasn't been documented, sorry. One of the ways to fix this in Got would be to always pass the entire agent object to the
request
function, but then we would need to defaultrequest
to something like this:But then
request: https.request
wouldn't work. We could detect nativehttp
functions but then it would fail on custom functions that at the end return the same whathttps.request
does.I'm not sure what's the best solution here. Alternatively we could make
request
an object with protocolshttp2
https
andhttp
as keys...For now
http2: true
does the trick :PIndeed. Can you point it down to a few lines? I suppose it's caused by too intensive object creation. The upcoming Got version uses getters & setters in order to avoid re-doing normalization if not necessary. If you could create a reproducible repo, that would be awesome.
Also feel free to create an issue in the Got repo about this :)