Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect baseUrl passed as part of request parameters #641

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading