Skip to content

Commit 3a28b7f

Browse files
committed
Change bool to possible undefined
1 parent bf1a442 commit 3a28b7f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/utils.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,21 +728,33 @@ class Utils {
728728
static getMarkdownFooter() {
729729
return '\n\n # \n\n The above Job Summary was generated by the <a href="https://github.com/marketplace/actions/setup-jfrog-cli"> Setup JFrog CLI GitHub Action </a>';
730730
}
731+
/**
732+
* Checks if the header image is accessible via the internet.
733+
* saves the result in a static variable to avoid multiple checks.
734+
* @private
735+
*/
731736
static isHeaderPngAccessible() {
732737
return __awaiter(this, void 0, void 0, function* () {
738+
if (this.isSummaryHeaderAccessible != undefined) {
739+
return this.isSummaryHeaderAccessible;
740+
}
733741
const url = this.MARKDOWN_HEADER_PNG_URL;
734742
const httpClient = new http_client_1.HttpClient();
735743
try {
736-
const response = yield httpClient.head(url);
737-
return response.message.statusCode === 200;
744+
const requestOptions = {
745+
socketTimeout: 5000, // Set timeout to 5 seconds
746+
};
747+
const response = yield httpClient.head(url, requestOptions);
748+
this.isSummaryHeaderAccessible = response.message.statusCode === 200;
738749
}
739750
catch (error) {
740751
core.warning('No internet access to the header image, using the text header instead.');
741-
return false;
752+
this.isSummaryHeaderAccessible = false;
742753
}
743754
finally {
744755
httpClient.dispose();
745756
}
757+
return this.isSummaryHeaderAccessible;
746758
});
747759
}
748760
static getTempDirectory() {
@@ -809,3 +821,5 @@ Utils.CUSTOM_SERVER_ID = 'custom-server-id';
809821
// It cannot be linked to the repository, as GitHub serves the image from a CDN,
810822
// which gets blocked by the browser, resulting in an empty image.
811823
Utils.MARKDOWN_HEADER_PNG_URL = 'https://media.jfrog.com/wp-content/uploads/2024/09/02161430/jfrog-job-summary.svg';
824+
// Flag to indicate if the summary header is accessible, can be undefined if not checked yet.
825+
Utils.isSummaryHeaderAccessible = undefined;

0 commit comments

Comments
 (0)