Use @adobe/node-fetch-retry instead of node-fetch. Fix #187

This commit is contained in:
Feng Yu 2022-01-23 11:16:16 +08:00
parent fe9a9bd329
commit 3f7b9fcbad
No known key found for this signature in database
GPG key ID: D57121CAD3189591
3 changed files with 36 additions and 4 deletions

31
package-lock.json generated
View file

@ -28,6 +28,15 @@
"tunnel": "0.0.6" "tunnel": "0.0.6"
} }
}, },
"@adobe/node-fetch-retry": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/@adobe/node-fetch-retry/download/@adobe/node-fetch-retry-2.0.0.tgz",
"integrity": "sha512-yqyY8yfHtVRMhy9JHiu9gVhnHVZfZRRTEWWinBGnSCLijLggslWdXsflOf80odzjRueQOzJl3/wbfzFeXpsNwA==",
"requires": {
"abort-controller": "^3.0.0",
"node-fetch": "^2.6.1"
}
},
"@babel/code-frame": { "@babel/code-frame": {
"version": "7.5.5", "version": "7.5.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
@ -536,6 +545,15 @@
"@octokit/openapi-types": "^9.2.0" "@octokit/openapi-types": "^9.2.0"
} }
}, },
"@types/adobe__node-fetch-retry": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/@types/adobe__node-fetch-retry/download/@types/adobe__node-fetch-retry-1.0.3.tgz",
"integrity": "sha512-uAK2VB1zaK71u+Vgaok81Fy4tFugr2Sl7EhECvRBnSn+TNWGY2f15Q8/arKTw+wJFVTb9QciDz0hwDS+lCwyYg==",
"dev": true,
"requires": {
"@types/node-fetch": "^2.5.12"
}
},
"@types/babel__core": { "@types/babel__core": {
"version": "7.1.3", "version": "7.1.3",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz",
@ -702,6 +720,14 @@
"integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw==", "integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw==",
"dev": true "dev": true
}, },
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmmirror.com/abort-controller/download/abort-controller-3.0.0.tgz",
"integrity": "sha1-6vVNU7YrrkE46AnKIlyEOabvs5I=",
"requires": {
"event-target-shim": "^5.0.0"
}
},
"acorn": { "acorn": {
"version": "5.7.3", "version": "5.7.3",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz",
@ -1533,6 +1559,11 @@
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true "dev": true
}, },
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmmirror.com/event-target-shim/download/event-target-shim-5.0.1.tgz",
"integrity": "sha1-XU0+vflYPWOlMzzi3rdICrKwV4k="
},
"exec-sh": { "exec-sh": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.2.tgz", "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.2.tgz",

View file

@ -22,13 +22,14 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.4.0", "@actions/core": "^1.4.0",
"@actions/github": "^5.0.0", "@actions/github": "^5.0.0",
"@adobe/node-fetch-retry": "^2.0.0",
"@octokit/plugin-retry": "^3.0.9", "@octokit/plugin-retry": "^3.0.9",
"@octokit/plugin-throttling": "^3.5.1", "@octokit/plugin-throttling": "^3.5.1",
"glob": "^7.1.6", "glob": "^7.1.6",
"mime": "^2.4.4", "mime": "^2.4.4"
"node-fetch": "^2.6.1"
}, },
"devDependencies": { "devDependencies": {
"@types/adobe__node-fetch-retry": "^1.0.3",
"@types/glob": "^7.1.1", "@types/glob": "^7.1.1",
"@types/jest": "^24.0.25", "@types/jest": "^24.0.25",
"@types/mime": "^2.0.1", "@types/mime": "^2.0.1",

View file

@ -1,4 +1,4 @@
import fetch from "node-fetch"; import fetch from "@adobe/node-fetch-retry";
import { GitHub } from "@actions/github/lib/utils"; import { GitHub } from "@actions/github/lib/utils";
import { Config, isTag, releaseBody } from "./util"; import { Config, isTag, releaseBody } from "./util";
import { statSync, readFileSync } from "fs"; import { statSync, readFileSync } from "fs";
@ -159,7 +159,7 @@ export const upload = async (
console.log(`⬆️ Uploading ${name}...`); console.log(`⬆️ Uploading ${name}...`);
const endpoint = new URL(url); const endpoint = new URL(url);
endpoint.searchParams.append("name", name); endpoint.searchParams.append("name", name);
const resp = await fetch(endpoint, { const resp = await fetch(endpoint.toString(), {
headers: { headers: {
"content-length": `${size}`, "content-length": `${size}`,
"content-type": mime, "content-type": mime,