Skip to content

Commit

Permalink
Merge pull request #63 from DeterminateSystems/retry-streams
Browse files Browse the repository at this point in the history
Retry streams
  • Loading branch information
grahamc authored Sep 4, 2024
2 parents 817e4d4 + e88434e commit 65dd73c
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 46 deletions.
6 changes: 4 additions & 2 deletions dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 71 additions & 20 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/ids-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ALLOWED_SUFFIXES = [
const DEFAULT_IDS_HOST = "https://install.determinate.systems";
const LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP;

const DEFAULT_TIMEOUT = 30_000; // 30 seconds in milliseconds
const DEFAULT_TIMEOUT = 10_000; // 10 seconds in ms

/**
* Host information for install.determinate.systems.
Expand All @@ -41,7 +41,11 @@ export class IdsHost {
}

async getGot(
recordFailoverCallback?: (prevUrl: URL, nextUrl: URL) => void,
recordFailoverCallback?: (
incitingError: unknown,
prevUrl: URL,
nextUrl: URL,
) => void,
): Promise<Got> {
if (this.client === undefined) {
this.client = got.extend({
Expand All @@ -50,7 +54,7 @@ export class IdsHost {
},

retry: {
limit: (await this.getUrlsByPreference()).length,
limit: Math.max((await this.getUrlsByPreference()).length, 3),
methods: ["GET", "HEAD"],
},

Expand All @@ -62,7 +66,7 @@ export class IdsHost {
const nextUrl = await this.getRootUrl();

if (recordFailoverCallback !== undefined) {
recordFailoverCallback(prevUrl, nextUrl);
recordFailoverCallback(error, prevUrl, nextUrl);
}

actionsCore.info(
Expand Down
Loading

0 comments on commit 65dd73c

Please sign in to comment.