Update detsys-ts for: Merge pull request #63 from DeterminateSystems/retry-streams (65dd73c562ac60a068340f8e0c040bdcf2c59afe) (#120)

Co-authored-by: grahamc <76716+grahamc@users.noreply.github.com>
This commit is contained in:
detsys-pr-bot 2024-09-04 11:14:02 -07:00 committed by GitHub
parent 1406b8b52c
commit da36cb69b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 70 additions and 24 deletions

88
dist/index.js generated vendored
View file

@ -96403,9 +96403,7 @@ const external_node_dns_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequ
var cache = __nccwpck_require__(6878); var cache = __nccwpck_require__(6878);
;// CONCATENATED MODULE: external "node:child_process" ;// CONCATENATED MODULE: external "node:child_process"
const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process"); const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process");
;// CONCATENATED MODULE: external "node:stream/promises" ;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@65dd73c562ac60a068340f8e0c040bdcf2c59afe_eek3lsas7notlem5iqjfyrzcca/node_modules/detsys-ts/dist/index.js
const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@817e4d4123b6fb4eae5aa557658f25f8539e7240_cyq6j27kjpra3jtdpg5422ffka/node_modules/detsys-ts/dist/index.js
var __defProp = Object.defineProperty; var __defProp = Object.defineProperty;
var __export = (target, all) => { var __export = (target, all) => {
for (var name in all) for (var name in all)
@ -96879,7 +96877,7 @@ var ALLOWED_SUFFIXES = [
]; ];
var DEFAULT_IDS_HOST = "https://install.determinate.systems"; var DEFAULT_IDS_HOST = "https://install.determinate.systems";
var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP;
var DEFAULT_TIMEOUT = 3e4; var DEFAULT_TIMEOUT = 1e4;
var IdsHost = class { var IdsHost = class {
constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) { constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) {
this.idsProjectName = idsProjectName; this.idsProjectName = idsProjectName;
@ -96894,7 +96892,7 @@ var IdsHost = class {
request: DEFAULT_TIMEOUT request: DEFAULT_TIMEOUT
}, },
retry: { retry: {
limit: (await this.getUrlsByPreference()).length, limit: Math.max((await this.getUrlsByPreference()).length, 3),
methods: ["GET", "HEAD"] methods: ["GET", "HEAD"]
}, },
hooks: { hooks: {
@ -96904,7 +96902,7 @@ var IdsHost = class {
this.markCurrentHostBroken(); this.markCurrentHostBroken();
const nextUrl = await this.getRootUrl(); const nextUrl = await this.getRootUrl();
if (recordFailoverCallback !== void 0) { if (recordFailoverCallback !== void 0) {
recordFailoverCallback(prevUrl, nextUrl); recordFailoverCallback(error3, prevUrl, nextUrl);
} }
core.info( core.info(
`Retrying after error ${error3.code}, retry #: ${retryCount}` `Retrying after error ${error3.code}, retry #: ${retryCount}`
@ -97290,8 +97288,8 @@ var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found";
var STATE_NOT_FOUND = "not-found"; var STATE_NOT_FOUND = "not-found";
var STATE_KEY_CROSS_PHASE_ID = "detsys_cross_phase_id"; var STATE_KEY_CROSS_PHASE_ID = "detsys_cross_phase_id";
var STATE_BACKTRACE_START_TIMESTAMP = "detsys_backtrace_start_timestamp"; var STATE_BACKTRACE_START_TIMESTAMP = "detsys_backtrace_start_timestamp";
var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4; var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 1e4;
var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3; var CHECK_IN_ENDPOINT_TIMEOUT_MS = 1e3;
var DetSysAction = class { var DetSysAction = class {
determineExecutionPhase() { determineExecutionPhase() {
const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE); const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE);
@ -97515,12 +97513,15 @@ var DetSysAction = class {
} }
} }
async getClient() { async getClient() {
return await this.idsHost.getGot((prevUrl, nextUrl) => { return await this.idsHost.getGot(
this.recordEvent("ids-failover", { (incitingError, prevUrl, nextUrl) => {
previousUrl: prevUrl.toString(), this.recordPlausibleTimeout(incitingError);
nextUrl: nextUrl.toString() this.recordEvent("ids-failover", {
}); previousUrl: prevUrl.toString(),
}); nextUrl: nextUrl.toString()
});
}
);
} }
async checkIn() { async checkIn() {
const checkin = await this.requestCheckIn(); const checkin = await this.requestCheckIn();
@ -97604,12 +97605,27 @@ var DetSysAction = class {
} }
}).json(); }).json();
} catch (e) { } catch (e) {
this.recordPlausibleTimeout(e);
core.debug(`Error checking in: ${stringifyError2(e)}`); core.debug(`Error checking in: ${stringifyError2(e)}`);
this.idsHost.markCurrentHostBroken(); this.idsHost.markCurrentHostBroken();
} }
} }
return void 0; return void 0;
} }
recordPlausibleTimeout(e) {
if (e instanceof TimeoutError && "timings" in e && "request" in e) {
const reportContext = {
url: e.request.requestUrl?.toString(),
retry_count: e.request.retryCount
};
for (const [key, value] of Object.entries(e.timings.phases)) {
if (Number.isFinite(value)) {
reportContext[`timing_phase_${key}`] = value;
}
}
this.recordEvent("timeout", reportContext);
}
}
/** /**
* Fetch an artifact, such as a tarball, from the location determined by the * Fetch an artifact, such as a tarball, from the location determined by the
* `source-*` inputs. If `source-binary` is specified, this will return a path * `source-*` inputs. If `source-binary` is specified, this will return a path
@ -97653,13 +97669,9 @@ var DetSysAction = class {
`No match from the cache, re-fetching from the redirect: ${versionCheckup.url}` `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`
); );
const destFile = this.getTemporaryName(); const destFile = this.getTemporaryName();
const fetchStream = (await this.getClient()).stream(versionCheckup.url); const fetchStream = await this.downloadFile(
await (0,external_node_stream_promises_namespaceObject.pipeline)( new URL(versionCheckup.url),
fetchStream, destFile
(0,external_node_fs_namespaceObject.createWriteStream)(destFile, {
encoding: "binary",
mode: 493
})
); );
if (fetchStream.response?.headers.etag) { if (fetchStream.response?.headers.etag) {
const v = fetchStream.response.headers.etag; const v = fetchStream.response.headers.etag;
@ -97670,6 +97682,9 @@ var DetSysAction = class {
} }
} }
return destFile; return destFile;
} catch (e) {
this.recordPlausibleTimeout(e);
throw e;
} finally { } finally {
core.endGroup(); core.endGroup();
} }
@ -97683,6 +97698,36 @@ var DetSysAction = class {
core.setFailed(`strict mode failure: ${msg}`); core.setFailed(`strict mode failure: ${msg}`);
} }
} }
async downloadFile(url, destination) {
const client = await this.getClient();
return new Promise((resolve, reject) => {
let writeStream;
let failed = false;
const retry = (stream) => {
if (writeStream) {
writeStream.destroy();
}
writeStream = (0,external_node_fs_namespaceObject.createWriteStream)(destination, {
encoding: "binary",
mode: 493
});
writeStream.once("error", (error3) => {
failed = true;
reject(error3);
});
writeStream.on("finish", () => {
if (!failed) {
resolve(stream);
}
});
stream.once("retry", (_count, _error, createRetryStream) => {
retry(createRetryStream());
});
stream.pipe(writeStream);
};
retry(client.stream(url));
});
}
async complete() { async complete() {
this.recordEvent(`complete_${this.executionPhase}`); this.recordEvent(`complete_${this.executionPhase}`);
await this.submitEvents(); await this.submitEvents();
@ -97906,6 +97951,7 @@ var DetSysAction = class {
} }
}); });
} catch (err) { } catch (err) {
this.recordPlausibleTimeout(err);
core.debug( core.debug(
`Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}` `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}`
); );

View file

@ -16,7 +16,7 @@ dependencies:
version: 5.1.1 version: 5.1.1
detsys-ts: detsys-ts:
specifier: github:DeterminateSystems/detsys-ts specifier: github:DeterminateSystems/detsys-ts
version: github.com/DeterminateSystems/detsys-ts/817e4d4123b6fb4eae5aa557658f25f8539e7240 version: github.com/DeterminateSystems/detsys-ts/65dd73c562ac60a068340f8e0c040bdcf2c59afe
got: got:
specifier: ^14.3.0 specifier: ^14.3.0
version: 14.3.0 version: 14.3.0
@ -5685,10 +5685,10 @@ packages:
engines: { node: ">=10" } engines: { node: ">=10" }
dev: true dev: true
github.com/DeterminateSystems/detsys-ts/817e4d4123b6fb4eae5aa557658f25f8539e7240: github.com/DeterminateSystems/detsys-ts/65dd73c562ac60a068340f8e0c040bdcf2c59afe:
resolution: resolution:
{ {
tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/817e4d4123b6fb4eae5aa557658f25f8539e7240, tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/65dd73c562ac60a068340f8e0c040bdcf2c59afe,
} }
name: detsys-ts name: detsys-ts
version: 1.0.0 version: 1.0.0