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

Reduce isHeaderPngAccessible() timeout #235

Merged
merged 9 commits into from
Dec 26, 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
Prev Previous commit
Next Next commit
Change bool to possible undefined
EyalDelarea committed Dec 15, 2024
commit bf1a4428cc61dfacae161c97f0a3138fe5897058
10 changes: 7 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -70,7 +70,8 @@ export class Utils {
// It cannot be linked to the repository, as GitHub serves the image from a CDN,
// which gets blocked by the browser, resulting in an empty image.
private static MARKDOWN_HEADER_PNG_URL: string = 'https://media.jfrog.com/wp-content/uploads/2024/09/02161430/jfrog-job-summary.svg';
private static isSummaryHeaderAccessible: boolean;
// Flag to indicate if the summary header is accessible, can be undefined if not checked yet.
private static isSummaryHeaderAccessible: boolean | undefined = undefined;

/**
* Retrieves server credentials for accessing JFrog's server
@@ -806,13 +807,16 @@ export class Utils {
* @private
*/
private static async isHeaderPngAccessible(): Promise<boolean> {
// const url: string = this.MARKDOWN_HEADER_PNG_URL;
if (this.isSummaryHeaderAccessible != undefined) {
return this.isSummaryHeaderAccessible;
}
const url: string = this.MARKDOWN_HEADER_PNG_URL;
const httpClient: HttpClient = new HttpClient();
try {
const requestOptions: OutgoingHttpHeaders = {
socketTimeout: 5000, // Set timeout to 5 seconds
EyalDelarea marked this conversation as resolved.
Show resolved Hide resolved
};
const response: HttpClientResponse = await httpClient.head('https://some-not-a-real-url-for-test.com', requestOptions);
const response: HttpClientResponse = await httpClient.head(url, requestOptions);
this.isSummaryHeaderAccessible = response.message.statusCode === 200;
} catch (error) {
core.warning('No internet access to the header image, using the text header instead.');