From 5a618f9c7b8d15aed33a318a63d45327bc969037 Mon Sep 17 00:00:00 2001 From: "Takuya \"Mura-Mi\" Murakami" Date: Sat, 5 Oct 2024 21:41:25 +0900 Subject: [PATCH 1/2] feat: support https proxy --- package-lock.json | 5 +++-- package.json | 1 + src/version.mjs | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e49f9e..fd0ff19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "setup-deno", - "version": "1.5.0", + "version": "1.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "setup-deno", - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "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" diff --git a/package.json b/package.json index cdeb698..c719430 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/version.mjs b/src/version.mjs index 8f5f8f8..c89e4d4 100644 --- a/src/version.mjs +++ b/src/version.mjs @@ -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}$/; @@ -188,12 +189,17 @@ 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 }, + ); if (res.status === 200 || iterationCount > maxRetries) { return res; } From b3b60bcda0f82aaeb939e09b3e2f6378cde53308 Mon Sep 17 00:00:00 2001 From: "Takuya \"Mura-Mi\" Murakami" Date: Sat, 5 Oct 2024 22:00:07 +0900 Subject: [PATCH 2/2] chore: ignore TS2322 --- src/version.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/version.mjs b/src/version.mjs index c89e4d4..519d156 100644 --- a/src/version.mjs +++ b/src/version.mjs @@ -198,6 +198,9 @@ async function fetchWithRetries(url, maxRetries = 5) { try { 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 }, ); if (res.status === 200 || iterationCount > maxRetries) {