-
Notifications
You must be signed in to change notification settings - Fork 63
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
fix: remove custom proxy handling #143
Draft
parkerbxyz
wants to merge
17
commits into
main
Choose a base branch
from
134-remove-custom-proxy-functionality
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+14,580
−11,681
Draft
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ae98c18
fix: remove custom proxy handling
parkerbxyz 98eac26
fix: use unidici fetch
parkerbxyz fa33f86
Update code comment
parkerbxyz 5cb4b2f
fix: implement `EnvHttpProxyAgent`
parkerbxyz 28dfb1e
Merge branch 'main' into pr/143
parkerbxyz 19e441f
Merge branch 'main' into 134-remove-custom-proxy-functionality
parkerbxyz 1f00388
Update node version for `undici` proxy support
parkerbxyz 6aa1ac7
Don't warn if using a node version greater than 20
parkerbxyz 073d254
Remove `EnvHttpProxyAgent` implementation
parkerbxyz adf089d
Update package-lock.json
parkerbxyz 4e61ab3
Update dist files
parkerbxyz ed89981
Merge branch 'main' into pr/143
parkerbxyz 02b34af
Re-implement `EnvHttpProxyAgent` as local agent
parkerbxyz ff0675e
Use native fetch
parkerbxyz 7a505dc
Update dist files
parkerbxyz a0d0cbe
Merge branch 'main' into 134-remove-custom-proxy-functionality
parkerbxyz 489a969
Re-implement global dispatcher
parkerbxyz 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
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
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,10 @@ | ||
import core from "@actions/core"; | ||
import { request } from "@octokit/request"; | ||
import { ProxyAgent, fetch as undiciFetch } from "undici"; | ||
|
||
const baseUrl = core.getInput("github-api-url").replace(/\/$/, ""); | ||
|
||
// https://docs.github.com/actions/hosting-your-own-runners/managing-self-hosted-runners/using-a-proxy-server-with-self-hosted-runners | ||
const proxyUrl = | ||
process.env.https_proxy || | ||
process.env.HTTPS_PROXY || | ||
process.env.http_proxy || | ||
process.env.HTTP_PROXY; | ||
|
||
/* c8 ignore start */ | ||
// Native support for proxies in Undici is under consideration: https://github.com/nodejs/undici/issues/1650 | ||
// Until then, we need to use a custom fetch function to add proxy support. | ||
const proxyFetch = (url, options) => { | ||
const urlHost = new URL(url).hostname; | ||
const noProxy = (process.env.no_proxy || process.env.NO_PROXY || "").split( | ||
"," | ||
); | ||
|
||
if (!noProxy.includes(urlHost)) { | ||
options = { | ||
...options, | ||
dispatcher: new ProxyAgent(String(proxyUrl)), | ||
}; | ||
} | ||
|
||
return undiciFetch(url, options); | ||
}; | ||
/* c8 ignore stop */ | ||
|
||
export default request.defaults({ | ||
headers: { | ||
"user-agent": "actions/create-github-app-token", | ||
}, | ||
baseUrl, | ||
/* c8 ignore next */ | ||
request: proxyUrl ? { fetch: proxyFetch } : {}, | ||
}); |
Oops, something went wrong.
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.
I wonder if we need to explicitly use
EnvHttpProxyAgent
?https://github.com/nodejs/undici/blob/7f635e51f6170f4b59abedc7cb45e6bcda7f056d/docs/docs/api/EnvHttpProxyAgent.md#L4
See this comment: nodejs/undici#1650 (comment)
I just wanted to leave that not for when we have another look at it, I don't have time to dig into it now
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 tried that in 5cb4b2f, but several tests started failing as a result. After reading through nodejs/undici#2994, I got the impression it was unnecessary to do this.
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.
Super random drive-by comment. I got here from that issue. 😅
According to this commit, they ended up not using this as the default agent:
nodejs/undici@f31d3f9
Reasoning:
nodejs/undici#2994 (comment)
So it appears the PR description is wrong. Looks like they'll consider making it the default in a major release.
For now, I was able to get HTTPS_PROXY env variable to work via:
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, @bruce-c-liu! I found some additional context here:
https://github.com/nodejs/TSC/blob/41602b95211f30107696a007e5da45b9e933536c/meetings/2024-09-04.md?plain=1#L88-L115