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: support https proxy #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "module",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/http-client": "^2.2.3",
"@actions/tool-cache": "^2.0.1",
"semver": "^7.6.3",
"undici": "^6.19.8"
Expand Down
11 changes: 10 additions & 1 deletion src/version.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import semver from "semver";
import { fetch } from "undici";
import * as fs from "node:fs";
import { HttpClient } from "@actions/http-client";

const GIT_HASH_RE = /^[0-9a-fA-F]{40}$/;

Expand Down Expand Up @@ -188,12 +189,20 @@ async function resolveRelease(range) {

/** @param {string} url */
async function fetchWithRetries(url, maxRetries = 5) {
const dispatcher = new HttpClient().getAgentDispatcher(url);

let sleepMs = 250;
let iterationCount = 0;
while (true) {
iterationCount++;
try {
const res = await fetch(url);
const res = await fetch(
url,
// dispatcher is `ProxyAgent | undefined`, which is assignable to `Dispatcher | undefined` because
// ProxyAgent extends Dispatcher, but TS2322 is reported.
// @ts-ignore:
{ dispatcher },
Comment on lines +201 to +204
Copy link
Author

Choose a reason for hiding this comment

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

Without this, following ts error is shown.

error: TS2322 [ERROR]: Type 'ProxyAgent | undefined' is not assignable to type 'Dispatcher | undefined'.
  Property 'compose' is missing in type 'ProxyAgent' but required in type 'Dispatcher'.

undici's ProxyAgent extends undici's Dispatcher, so it seems false-positive.
Is this @ts-ignore acceptable?

);
if (res.status === 200 || iterationCount > maxRetries) {
return res;
}
Expand Down
Loading