-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Use Node-Fetch instead of Request for TS client #19708
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
Conversation
// fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one | ||
fetchType = requireFunc("fetch-cookie")(fetchType, jar); | ||
|
||
// Node needs EventListener methods on AbortController which our custom polyfill doesn't provide |
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.
How complex would it be to add it to our polyfill?
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.
Difficult because I have no idea how to work with the EventListener API.
I gave it a quick try and failed miserably.
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.
I guess we can't just use https://nodejs.org/api/events.html because our polyfill still has to work on the browser.
@@ -97,6 +124,15 @@ export class FetchHttpClient extends HttpClient { | |||
payload, | |||
); | |||
} | |||
|
|||
public getCookieString(url: string): string { |
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.
What's this for?
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.
It's the way we apply cookies to WebSockets and SSE
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.
So where do we call it? I don't see it in the diff anywhere and it looks new.
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.
It isn't new. It just has a default implementation and since the FetchHttpClient
wasn't used in Node before it wasn't needed. But now it is.
One usage.
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 riiiiight. Ok, thanks for clearing that up. Just saw a new public API and was confused. There's a good reason C# has the override
keyword ;P.
The
request
module has been deprecated, so we're taking this opportunity to share our fetch code with the browser and Node by using a fetch polyfill on Node.Fixes #19420