Skip to content

Commit 8da9e38

Browse files
authored
Merge pull request #159 from detsys-pr-bot/detsys-ts-update-65dd73c562ac60a068340f8e0c040bdcf2c59afe
Update `detsys-ts`: Merge pull request #63 from DeterminateSystems/retry-streams
2 parents 405d127 + 16669a0 commit 8da9e38

File tree

2 files changed

+71
-25
lines changed

2 files changed

+71
-25
lines changed

dist/index.js

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93419,9 +93419,7 @@ var cache = __nccwpck_require__(6878);
9341993419
const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process");
9342093420
;// CONCATENATED MODULE: external "node:path"
9342193421
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
93422-
;// CONCATENATED MODULE: external "node:stream/promises"
93423-
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
93424-
;// CONCATENATED MODULE: ./node_modules/.pnpm/detsys-ts@https+++codeload.github.com+DeterminateSystems+detsys-ts+tar.gz+817e4d4123b6fb4eae5_xidqcuah7tnxkzkfyksdcuh3ni/node_modules/detsys-ts/dist/index.js
93422+
;// CONCATENATED MODULE: ./node_modules/.pnpm/detsys-ts@https+++codeload.github.com+DeterminateSystems+detsys-ts+tar.gz+65dd73c562ac60a0683_pugfuojoota6b26hy6vcd3ndou/node_modules/detsys-ts/dist/index.js
9342593423
var __defProp = Object.defineProperty;
9342693424
var __export = (target, all) => {
9342793425
for (var name in all)
@@ -93895,7 +93893,7 @@ var ALLOWED_SUFFIXES = [
9389593893
];
9389693894
var DEFAULT_IDS_HOST = "https://install.determinate.systems";
9389793895
var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP;
93898-
var DEFAULT_TIMEOUT = 3e4;
93896+
var DEFAULT_TIMEOUT = 1e4;
9389993897
var IdsHost = class {
9390093898
constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) {
9390193899
this.idsProjectName = idsProjectName;
@@ -93910,7 +93908,7 @@ var IdsHost = class {
9391093908
request: DEFAULT_TIMEOUT
9391193909
},
9391293910
retry: {
93913-
limit: (await this.getUrlsByPreference()).length,
93911+
limit: Math.max((await this.getUrlsByPreference()).length, 3),
9391493912
methods: ["GET", "HEAD"]
9391593913
},
9391693914
hooks: {
@@ -93920,7 +93918,7 @@ var IdsHost = class {
9392093918
this.markCurrentHostBroken();
9392193919
const nextUrl = await this.getRootUrl();
9392293920
if (recordFailoverCallback !== void 0) {
93923-
recordFailoverCallback(prevUrl, nextUrl);
93921+
recordFailoverCallback(error3, prevUrl, nextUrl);
9392493922
}
9392593923
core.info(
9392693924
`Retrying after error ${error3.code}, retry #: ${retryCount}`
@@ -94306,8 +94304,8 @@ var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found";
9430694304
var STATE_NOT_FOUND = "not-found";
9430794305
var STATE_KEY_CROSS_PHASE_ID = "detsys_cross_phase_id";
9430894306
var STATE_BACKTRACE_START_TIMESTAMP = "detsys_backtrace_start_timestamp";
94309-
var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4;
94310-
var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3;
94307+
var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 1e4;
94308+
var CHECK_IN_ENDPOINT_TIMEOUT_MS = 1e3;
9431194309
var DetSysAction = class {
9431294310
determineExecutionPhase() {
9431394311
const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE);
@@ -94531,12 +94529,15 @@ var DetSysAction = class {
9453194529
}
9453294530
}
9453394531
async getClient() {
94534-
return await this.idsHost.getGot((prevUrl, nextUrl) => {
94535-
this.recordEvent("ids-failover", {
94536-
previousUrl: prevUrl.toString(),
94537-
nextUrl: nextUrl.toString()
94538-
});
94539-
});
94532+
return await this.idsHost.getGot(
94533+
(incitingError, prevUrl, nextUrl) => {
94534+
this.recordPlausibleTimeout(incitingError);
94535+
this.recordEvent("ids-failover", {
94536+
previousUrl: prevUrl.toString(),
94537+
nextUrl: nextUrl.toString()
94538+
});
94539+
}
94540+
);
9454094541
}
9454194542
async checkIn() {
9454294543
const checkin = await this.requestCheckIn();
@@ -94620,12 +94621,27 @@ var DetSysAction = class {
9462094621
}
9462194622
}).json();
9462294623
} catch (e) {
94624+
this.recordPlausibleTimeout(e);
9462394625
core.debug(`Error checking in: ${stringifyError2(e)}`);
9462494626
this.idsHost.markCurrentHostBroken();
9462594627
}
9462694628
}
9462794629
return void 0;
9462894630
}
94631+
recordPlausibleTimeout(e) {
94632+
if (e instanceof TimeoutError && "timings" in e && "request" in e) {
94633+
const reportContext = {
94634+
url: e.request.requestUrl?.toString(),
94635+
retry_count: e.request.retryCount
94636+
};
94637+
for (const [key, value] of Object.entries(e.timings.phases)) {
94638+
if (Number.isFinite(value)) {
94639+
reportContext[`timing_phase_${key}`] = value;
94640+
}
94641+
}
94642+
this.recordEvent("timeout", reportContext);
94643+
}
94644+
}
9462994645
/**
9463094646
* Fetch an artifact, such as a tarball, from the location determined by the
9463194647
* `source-*` inputs. If `source-binary` is specified, this will return a path
@@ -94669,13 +94685,9 @@ var DetSysAction = class {
9466994685
`No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`
9467094686
);
9467194687
const destFile = this.getTemporaryName();
94672-
const fetchStream = (await this.getClient()).stream(versionCheckup.url);
94673-
await (0,external_node_stream_promises_namespaceObject.pipeline)(
94674-
fetchStream,
94675-
(0,external_node_fs_namespaceObject.createWriteStream)(destFile, {
94676-
encoding: "binary",
94677-
mode: 493
94678-
})
94688+
const fetchStream = await this.downloadFile(
94689+
new URL(versionCheckup.url),
94690+
destFile
9467994691
);
9468094692
if (fetchStream.response?.headers.etag) {
9468194693
const v = fetchStream.response.headers.etag;
@@ -94686,6 +94698,9 @@ var DetSysAction = class {
9468694698
}
9468794699
}
9468894700
return destFile;
94701+
} catch (e) {
94702+
this.recordPlausibleTimeout(e);
94703+
throw e;
9468994704
} finally {
9469094705
core.endGroup();
9469194706
}
@@ -94699,6 +94714,36 @@ var DetSysAction = class {
9469994714
core.setFailed(`strict mode failure: ${msg}`);
9470094715
}
9470194716
}
94717+
async downloadFile(url, destination) {
94718+
const client = await this.getClient();
94719+
return new Promise((resolve, reject) => {
94720+
let writeStream;
94721+
let failed = false;
94722+
const retry = (stream) => {
94723+
if (writeStream) {
94724+
writeStream.destroy();
94725+
}
94726+
writeStream = (0,external_node_fs_namespaceObject.createWriteStream)(destination, {
94727+
encoding: "binary",
94728+
mode: 493
94729+
});
94730+
writeStream.once("error", (error3) => {
94731+
failed = true;
94732+
reject(error3);
94733+
});
94734+
writeStream.on("finish", () => {
94735+
if (!failed) {
94736+
resolve(stream);
94737+
}
94738+
});
94739+
stream.once("retry", (_count, _error, createRetryStream) => {
94740+
retry(createRetryStream());
94741+
});
94742+
stream.pipe(writeStream);
94743+
};
94744+
retry(client.stream(url));
94745+
});
94746+
}
9470294747
async complete() {
9470394748
this.recordEvent(`complete_${this.executionPhase}`);
9470494749
await this.submitEvents();
@@ -94922,6 +94967,7 @@ var DetSysAction = class {
9492294967
}
9492394968
});
9492494969
} catch (err) {
94970+
this.recordPlausibleTimeout(err);
9492594971
core.debug(
9492694972
`Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}`
9492794973
);

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)