Update detsys-ts
for: Merge pull request #63 from DeterminateSystems/retry-streams
(65dd73c562ac60a068340f8e0c040bdcf2c59afe
)
This commit is contained in:
parent
7d80c329b4
commit
802501548e
2 changed files with 70 additions and 24 deletions
80
dist/index.js
vendored
80
dist/index.js
vendored
|
@ -93419,9 +93419,7 @@ var cache = __nccwpck_require__(6878);
|
||||||
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:path"
|
;// CONCATENATED MODULE: external "node:path"
|
||||||
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
|
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
|
||||||
;// 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)
|
||||||
|
@ -93895,7 +93893,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;
|
||||||
|
@ -93910,7 +93908,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: {
|
||||||
|
@ -93920,7 +93918,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}`
|
||||||
|
@ -94306,8 +94304,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);
|
||||||
|
@ -94531,12 +94529,15 @@ var DetSysAction = class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getClient() {
|
async getClient() {
|
||||||
return await this.idsHost.getGot((prevUrl, nextUrl) => {
|
return await this.idsHost.getGot(
|
||||||
|
(incitingError, prevUrl, nextUrl) => {
|
||||||
|
this.recordPlausibleTimeout(incitingError);
|
||||||
this.recordEvent("ids-failover", {
|
this.recordEvent("ids-failover", {
|
||||||
previousUrl: prevUrl.toString(),
|
previousUrl: prevUrl.toString(),
|
||||||
nextUrl: nextUrl.toString()
|
nextUrl: nextUrl.toString()
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
async checkIn() {
|
async checkIn() {
|
||||||
const checkin = await this.requestCheckIn();
|
const checkin = await this.requestCheckIn();
|
||||||
|
@ -94620,12 +94621,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
|
||||||
|
@ -94669,13 +94685,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;
|
||||||
|
@ -94686,6 +94698,9 @@ var DetSysAction = class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return destFile;
|
return destFile;
|
||||||
|
} catch (e) {
|
||||||
|
this.recordPlausibleTimeout(e);
|
||||||
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
@ -94699,6 +94714,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();
|
||||||
|
@ -94922,6 +94967,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)}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,7 +13,7 @@ dependencies:
|
||||||
version: 1.1.1
|
version: 1.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
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@trivago/prettier-plugin-sort-imports':
|
'@trivago/prettier-plugin-sort-imports':
|
||||||
|
@ -4645,8 +4645,8 @@ packages:
|
||||||
engines: {node: '>=12.20'}
|
engines: {node: '>=12.20'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
github.com/DeterminateSystems/detsys-ts/817e4d4123b6fb4eae5aa557658f25f8539e7240:
|
github.com/DeterminateSystems/detsys-ts/65dd73c562ac60a068340f8e0c040bdcf2c59afe:
|
||||||
resolution: {tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/817e4d4123b6fb4eae5aa557658f25f8539e7240}
|
resolution: {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
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
Loading…
Reference in a new issue