-
Notifications
You must be signed in to change notification settings - Fork 24
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
Pass node-fetch as options.request.fetch to the Octokit constructor #225
Conversation
Since the other Octokit modules that power this one dropped support for Node 16, it is going to be harder to keep support |
Agreed, and I don't like having a special case; can you think of another way to handle this? Currently, these are all kinda blocking each other:
I'm trying to find a clean path to move forward, but I keep walking into the agent support / node v16 walls. I'd love to hear thoughts or clarity from all that have been involved so far (@gr2m, @wolfy1339, @kfcampbell, @oscard0m) - I might be overthinking this or simply in need of a better perspective. I am sure we can come up with a decent path to get these last 3 libraries landed. Let me know y'alls thoughts. |
Undici supports Node 16, no problem. They implement an In diff --git a/src/index.ts b/src/index.ts
index 0998398..f293763 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -6,7 +6,7 @@ export type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-meth
import { VERSION } from "./version";
import type { OctokitOptions } from "@octokit/core/dist-types/types";
-import { HttpsProxyAgent } from "https-proxy-agent";
+import { fetch as undiciFetch, ProxyAgent } from "undici";
const DEFAULTS = {
authStrategy: createActionAuth,
@@ -17,16 +17,22 @@ const DEFAULTS = {
function getProxyAgent() {
const httpProxy = process.env["HTTP_PROXY"] || process.env["http_proxy"];
if (httpProxy) {
- return new HttpsProxyAgent(httpProxy);
+ return new ProxyAgent(httpProxy);
}
const httpsProxy = process.env["HTTPS_PROXY"] || process.env["https_proxy"];
if (httpsProxy) {
- return new HttpsProxyAgent(httpsProxy);
+ return new ProxyAgent(httpsProxy);
}
return undefined;
}
+const customFetch = async function(url: string, opts: any) {
+ return await undiciFetch(url, {
+ dispatcher: getProxyAgent(),
+ ...opts
+ });
+};
export const Octokit = Core.plugin(
paginateRest,
@@ -36,7 +42,7 @@ export const Octokit = Core.plugin(
...DEFAULTS,
...options,
request: {
- agent: getProxyAgent(),
+ fetch: customFetch,
...options.request,
},
}; |
I like @wolfy1339's approach 👍🏼 |
Implemented here: octokit/action.js#513 |
bd9eea8
to
2ca7eeb
Compare
Closing this as the fetch changes were handled in #221. |
After speaking with @gr2m we decided to pass in node-fetch (as an option) to the Octokit constructor now that request.js has changed.
This should ensure that the action will work as is without requiring a node bump and or changes on the consumer side (avoiding breaking changes)
Relates to #221
Behavior
Before the change?
After the change?