Merge pull request #32 from pnpm/retry-fetch

fix: retry fetch of pnpm script
This commit is contained in:
Khải 2022-02-21 10:28:16 +07:00 committed by GitHub
commit ad2b35ae0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 284 additions and 29 deletions

BIN
dist/index.js vendored

Binary file not shown.

View File

@ -8,6 +8,8 @@
},
"dependencies": {
"@actions/core": "^1.6.0",
"@pnpm/fetch": "^4.2.4",
"@pnpm/logger": "^4.0.0",
"@types/expand-tilde": "^2.0.0",
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.5",
@ -16,8 +18,7 @@
"ajv": "^6.12.6",
"expand-tilde": "^2.0.2",
"fs-extra": "^9.1.0",
"js-yaml": "^4.1.0",
"node-fetch": "^2.6.7"
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@ts-schema-autogen/cli": "^0.1.2",

View File

@ -2,6 +2,8 @@ lockfileVersion: 5.3
specifiers:
'@actions/core': ^1.6.0
'@pnpm/fetch': ^4.2.4
'@pnpm/logger': ^4.0.0
'@ts-schema-autogen/cli': ^0.1.2
'@types/expand-tilde': ^2.0.0
'@types/fs-extra': ^9.0.13
@ -13,11 +15,12 @@ specifiers:
expand-tilde: ^2.0.2
fs-extra: ^9.1.0
js-yaml: ^4.1.0
node-fetch: ^2.6.7
typescript: ^4.5.5
dependencies:
'@actions/core': 1.6.0
'@pnpm/fetch': 4.2.4_@pnpm+logger@4.0.0
'@pnpm/logger': 4.0.0
'@types/expand-tilde': 2.0.0
'@types/fs-extra': 9.0.13
'@types/js-yaml': 4.0.5
@ -27,7 +30,6 @@ dependencies:
expand-tilde: 2.0.2
fs-extra: 9.1.0
js-yaml: 4.1.0
node-fetch: 2.6.7
devDependencies:
'@ts-schema-autogen/cli': 0.1.2
@ -48,6 +50,74 @@ packages:
tunnel: 0.0.6
dev: false
/@pnpm/core-loggers/6.1.3_@pnpm+logger@4.0.0:
resolution: {integrity: sha512-X3mEhYz+8DKy4Xxbr24tGK9jPD+1AIhigGiJ9Fd0q+ywHXQ6ECSFyGGikKEAlBQIKVJxG788Mi0Zo13TU91fEQ==}
engines: {node: '>=12.17'}
peerDependencies:
'@pnpm/logger': ^4.0.0
dependencies:
'@pnpm/logger': 4.0.0
'@pnpm/types': 7.9.0
dev: false
/@pnpm/fetch/4.2.4_@pnpm+logger@4.0.0:
resolution: {integrity: sha512-PnFPVxhAK0+mOgKsVMrzS1bFokeO3PB6/aaBBjQprtvBG6jYZ8d8JnHvwhRcCKM/LxqVsazMFgqYPEFyMjg0Pw==}
engines: {node: '>=12.17'}
peerDependencies:
'@pnpm/logger': ^4.0.0
dependencies:
'@pnpm/core-loggers': 6.1.3_@pnpm+logger@4.0.0
'@pnpm/fetching-types': 2.2.1
'@pnpm/logger': 4.0.0
'@pnpm/npm-registry-agent': 5.0.2
'@zkochan/retry': 0.2.0
node-fetch: 3.0.0-beta.9
transitivePeerDependencies:
- domexception
- supports-color
dev: false
/@pnpm/fetching-types/2.2.1:
resolution: {integrity: sha512-ihcncWdo40GR91hRfuNtKnXUUczIDN+eJdRSu4/dTSRnAgi4HL/RN5RQ3l2XCT4ausmZvDjaO+LJx8/q4967tw==}
engines: {node: '>=12.17'}
dependencies:
'@zkochan/retry': 0.2.0
node-fetch: 3.0.0-beta.9
transitivePeerDependencies:
- domexception
dev: false
/@pnpm/logger/4.0.0:
resolution: {integrity: sha512-SIShw+k556e7S7tLZFVSIHjCdiVog1qWzcKW2RbLEHPItdisAFVNIe34kYd9fMSswTlSRLS/qRjw3ZblzWmJ9Q==}
engines: {node: '>=12.17'}
dependencies:
bole: 4.0.0
ndjson: 2.0.0
dev: false
/@pnpm/npm-registry-agent/5.0.2:
resolution: {integrity: sha512-HmdLnoD3LFquTq40RnbZoF2dwMrGAa2TG2WclKxmrRKj+6dOvhC/YztysVnv+/mfwn7Nlf4gBjOi8ZQz0F3C5g==}
engines: {node: '>=12.17'}
dependencies:
agentkeepalive: 4.2.0
http-proxy-agent: 5.0.0
https-proxy-agent: 5.0.0
lru-cache: 6.0.0
socks-proxy-agent: 6.1.1
transitivePeerDependencies:
- supports-color
dev: false
/@pnpm/types/7.9.0:
resolution: {integrity: sha512-WJol7zZKMktP8bvoFEh/ANCrYsIDcfpGFgRZmAMeULuskFVND4NLXXIkBqNhtmv+ipt6mVUnsZTGHrVaXrlsNA==}
engines: {node: '>=12.17'}
dev: false
/@tootallnate/once/2.0.0:
resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==}
engines: {node: '>= 10'}
dev: false
/@ts-schema-autogen/cli/0.1.2:
resolution: {integrity: sha512-61aIkJh7RDDNLCQJtp++1pL/LWlPAI9dxgWyhXycyRm4TRaTVaRBOoxTVnN0IVT+akdhWeiXkhNkCzG6Vd5zAw==}
hasBin: true
@ -245,6 +315,31 @@ packages:
hasBin: true
dev: true
/@zkochan/retry/0.2.0:
resolution: {integrity: sha512-WhB+2B/ZPlW2Xy/kMJBrMbqecWXcbDDgn0K0wKBAgO2OlBTz1iLJrRWduo+DGGn0Akvz1Lu4Xvls7dJojximWw==}
engines: {node: '>=10'}
dev: false
/agent-base/6.0.2:
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
engines: {node: '>= 6.0.0'}
dependencies:
debug: 4.3.3
transitivePeerDependencies:
- supports-color
dev: false
/agentkeepalive/4.2.0:
resolution: {integrity: sha512-0PhAp58jZNw13UJv7NVdTGb0ZcghHUb3DrZ046JiiJY/BOaTTpbwdHq2VObPCBV8M2GPh7sgrJ3AQ8Ey468LJw==}
engines: {node: '>= 8.0.0'}
dependencies:
debug: 4.3.3
depd: 1.1.2
humanize-ms: 1.2.1
transitivePeerDependencies:
- supports-color
dev: false
/ajv/6.12.6:
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
dependencies:
@ -307,6 +402,13 @@ packages:
tslib: 1.14.1
dev: true
/bole/4.0.0:
resolution: {integrity: sha512-Bk/2qoyOSlwU1dnDFk/oPM2FCNKAlYlBHfpAgwGX+K9HUtxSvmIAQCmMWMOvE6BlHHRCwsH1MxJe/r1ieodxqQ==}
dependencies:
fast-safe-stringify: 2.1.1
individual: 3.0.0
dev: false
/brace-expansion/1.1.11:
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
dependencies:
@ -367,6 +469,23 @@ packages:
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
dev: true
/data-uri-to-buffer/3.0.1:
resolution: {integrity: sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==}
engines: {node: '>= 6'}
dev: false
/debug/4.3.3:
resolution: {integrity: sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.1.2
dev: false
/decamelize/1.2.0:
resolution: {integrity: sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=}
engines: {node: '>=0.10.0'}
@ -377,6 +496,11 @@ packages:
engines: {node: '>=0.4.0'}
dev: false
/depd/1.1.2:
resolution: {integrity: sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=}
engines: {node: '>= 0.6'}
dev: false
/emoji-regex/7.0.3:
resolution: {integrity: sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==}
dev: true
@ -411,6 +535,10 @@ packages:
/fast-json-stable-stringify/2.1.0:
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
/fast-safe-stringify/2.1.1:
resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==}
dev: false
/fast-traverse/0.1.7:
resolution: {integrity: sha512-gZTQvJSgrGV24F8AeeTNxip8OEkjRHwDDpGw0b51TzRVGjJsKzh6CuHf9ltVjJZzni5Ead+EEQJ0IFCuoCJUtA==}
dependencies:
@ -418,6 +546,16 @@ packages:
tslib: 2.3.1
dev: true
/fetch-blob/2.1.2:
resolution: {integrity: sha512-YKqtUDwqLyfyMnmbw8XD6Q8j9i/HggKtPEI+pZ1+8bvheBu78biSmNaXWusx1TauGqtUUGx/cBb1mKdq2rLYow==}
engines: {node: ^10.17.0 || >=12.3.0}
peerDependencies:
domexception: '*'
peerDependenciesMeta:
domexception:
optional: true
dev: false
/find-up/3.0.0:
resolution: {integrity: sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==}
engines: {node: '>=6'}
@ -491,6 +629,37 @@ packages:
parse-passwd: 1.0.0
dev: false
/http-proxy-agent/5.0.0:
resolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==}
engines: {node: '>= 6'}
dependencies:
'@tootallnate/once': 2.0.0
agent-base: 6.0.2
debug: 4.3.3
transitivePeerDependencies:
- supports-color
dev: false
/https-proxy-agent/5.0.0:
resolution: {integrity: sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==}
engines: {node: '>= 6'}
dependencies:
agent-base: 6.0.2
debug: 4.3.3
transitivePeerDependencies:
- supports-color
dev: false
/humanize-ms/1.2.1:
resolution: {integrity: sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=}
dependencies:
ms: 2.1.3
dev: false
/individual/3.0.0:
resolution: {integrity: sha1-58pPhfiVewGHNPKFdQ3CLsL5hi0=}
dev: false
/inflight/1.0.6:
resolution: {integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=}
dependencies:
@ -500,7 +669,10 @@ packages:
/inherits/2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
dev: true
/ip/1.1.5:
resolution: {integrity: sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=}
dev: false
/is-fullwidth-code-point/2.0.0:
resolution: {integrity: sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=}
@ -536,6 +708,10 @@ packages:
jsonify: 0.0.0
dev: true
/json-stringify-safe/5.0.1:
resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=}
dev: false
/jsonfile/4.0.0:
resolution: {integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=}
optionalDependencies:
@ -569,6 +745,13 @@ packages:
p-locate: 4.1.0
dev: true
/lru-cache/6.0.0:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
engines: {node: '>=10'}
dependencies:
yallist: 4.0.0
dev: false
/mime-db/1.51.0:
resolution: {integrity: sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==}
engines: {node: '>= 0.6'}
@ -587,16 +770,38 @@ packages:
brace-expansion: 1.1.11
dev: true
/node-fetch/2.6.7:
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
engines: {node: 4.x || >=6.0.0}
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
/minimist/1.2.5:
resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==}
dev: false
/ms/2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
dev: false
/ms/2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: false
/ndjson/2.0.0:
resolution: {integrity: sha512-nGl7LRGrzugTtaFcJMhLbpzJM6XdivmbkdlaGcrk/LXg2KL/YBC6z1g70xh0/al+oFuVFP8N8kiWRucmeEH/qQ==}
engines: {node: '>=10'}
hasBin: true
dependencies:
whatwg-url: 5.0.0
json-stringify-safe: 5.0.1
minimist: 1.2.5
readable-stream: 3.6.0
split2: 3.2.2
through2: 4.0.2
dev: false
/node-fetch/3.0.0-beta.9:
resolution: {integrity: sha512-RdbZCEynH2tH46+tj0ua9caUHVWrd/RHnRfvly2EVdqGmI3ndS1Vn/xjm5KuGejDt2RNDQsVRLPNd2QPwcewVg==}
engines: {node: ^10.17 || >=12.3}
dependencies:
data-uri-to-buffer: 3.0.1
fetch-blob: 2.1.2
transitivePeerDependencies:
- domexception
dev: false
/once/1.4.0:
@ -655,6 +860,15 @@ packages:
resolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==}
engines: {node: '>=6'}
/readable-stream/3.6.0:
resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==}
engines: {node: '>= 6'}
dependencies:
inherits: 2.0.4
string_decoder: 1.3.0
util-deprecate: 1.0.2
dev: false
/require-directory/2.1.1:
resolution: {integrity: sha1-jGStX9MNqxyXbiNE/+f3kqam30I=}
engines: {node: '>=0.10.0'}
@ -664,10 +878,44 @@ packages:
resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==}
dev: true
/safe-buffer/5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false
/set-blocking/2.0.0:
resolution: {integrity: sha1-BF+XgtARrppoA93TgrJDkrPYkPc=}
dev: true
/smart-buffer/4.2.0:
resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==}
engines: {node: '>= 6.0.0', npm: '>= 3.0.0'}
dev: false
/socks-proxy-agent/6.1.1:
resolution: {integrity: sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==}
engines: {node: '>= 10'}
dependencies:
agent-base: 6.0.2
debug: 4.3.3
socks: 2.6.2
transitivePeerDependencies:
- supports-color
dev: false
/socks/2.6.2:
resolution: {integrity: sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==}
engines: {node: '>= 10.13.0', npm: '>= 3.0.0'}
dependencies:
ip: 1.1.5
smart-buffer: 4.2.0
dev: false
/split2/3.2.2:
resolution: {integrity: sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==}
dependencies:
readable-stream: 3.6.0
dev: false
/sprintf-js/1.0.3:
resolution: {integrity: sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=}
dev: true
@ -690,6 +938,12 @@ packages:
strip-ansi: 6.0.1
dev: true
/string_decoder/1.3.0:
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
dependencies:
safe-buffer: 5.2.1
dev: false
/strip-ansi/5.2.0:
resolution: {integrity: sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==}
engines: {node: '>=6'}
@ -704,8 +958,10 @@ packages:
ansi-regex: 5.0.1
dev: true
/tr46/0.0.3:
resolution: {integrity: sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=}
/through2/4.0.2:
resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==}
dependencies:
readable-stream: 3.6.0
dev: false
/tslib/1.14.1:
@ -759,22 +1015,15 @@ packages:
dependencies:
punycode: 2.1.1
/util-deprecate/1.0.2:
resolution: {integrity: sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=}
dev: false
/utility-types/3.10.0:
resolution: {integrity: sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==}
engines: {node: '>= 4'}
dev: true
/webidl-conversions/3.0.1:
resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=}
dev: false
/whatwg-url/5.0.0:
resolution: {integrity: sha1-lmRU6HZUYuN2RNNib2dCzotwll0=}
dependencies:
tr46: 0.0.3
webidl-conversions: 3.0.1
dev: false
/which-module/2.0.0:
resolution: {integrity: sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=}
dev: true
@ -805,6 +1054,10 @@ packages:
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
dev: true
/yallist/4.0.0:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
dev: false
/yargs-parser/15.0.3:
resolution: {integrity: sha512-/MVEVjTXy/cGAjdtQf8dW3V9b97bPN7rNn8ETj6BmAQL7ibC7O1Q9SPJbGjgh3SlwoBNXMzj/ZGIj8mBgl12YA==}
dependencies:

View File

@ -3,7 +3,7 @@ import { spawn } from 'child_process'
import { execPath } from 'process'
import path from 'path'
import { remove, ensureFile, writeFile } from 'fs-extra'
import fetch from 'node-fetch'
import fetch from '@pnpm/fetch'
import { Inputs } from '../inputs'
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
@ -20,7 +20,8 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
stdio: ['pipe', 'inherit', 'inherit'],
})
const response = await fetch('https://pnpm.io/pnpm.js')
const response = await fetch('https://get.pnpm.io/v6.16.js')
if (!response.body) throw new Error('Did not receive response body')
response.body.pipe(cp.stdin)
const exitCode = await new Promise<number>((resolve, reject) => {