Skip to content

Commit

Permalink
fix: respect baseUrl passed as part of request parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Sep 3, 2024
1 parent 447852f commit 281b392
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function hook(
const diff = Math.floor(
(Date.parse(error.response.headers.date) -
Date.parse(new Date().toString())) /
1000,
1000,
);

state.log.warn(error.message);
Expand Down Expand Up @@ -92,7 +92,7 @@ export async function hook(
state,
// @ts-expect-error TBD
{},
request,
request.defaults({ baseUrl: endpoint.baseUrl }),
);

endpoint.headers.authorization = `token ${token}`;
Expand Down Expand Up @@ -131,9 +131,8 @@ async function sendRequestWithRetries(

if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
if (retries > 0) {
error.message = `After ${retries} retries within ${
timeSinceTokenCreationInMs / 1000
}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1000
}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
}
throw error;
}
Expand All @@ -142,8 +141,7 @@ async function sendRequestWithRetries(

const awaitTime = retries * 1000;
state.log.warn(
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${
awaitTime / 1000
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1000
}s)`,
);
await new Promise((resolve) => setTimeout(resolve, awaitTime));
Expand Down

0 comments on commit 281b392

Please sign in to comment.