Skip to content

Change Binary Download Distribution #161

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

amaanbs
Copy link
Collaborator

@amaanbs amaanbs commented Jun 5, 2025

No description provided.

@amaanbs amaanbs requested a review from a team as a code owner June 5, 2025 22:58
@07souravkunda 07souravkunda requested a review from Copilot June 10, 2025 08:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the binary download distribution functionality by modifying the API of the binaryPath method and enhancing error handling. Key changes include:

  • Updating calls to binaryPath in tests to incorporate additional parameters (key and retries).
  • Introducing a new module (fetchDownloadSourceUrl.js) to retrieve download endpoints.
  • Changing the binary download logic and error reporting in LocalBinary.js and Local.js to support updated configurations.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/local.js Updated tests to pass additional parameters to binaryPath.
lib/fetchDownloadSourceUrl.js New module to fetch download source URL over HTTPS.
lib/LocalBinary.js Modified binaryPath API and improved error handling in downloads.
lib/Local.js Adjusted retries and updated binaryPath invocations accordingly.
Comments suppressed due to low confidence (1)

test/local.js:283

  • [nitpick] Document the use of the hard-coded test values ('abc' for key and 9 for retries) so that their purpose is clear to future maintainers.
(new LocalBinary()).binaryPath({}, 'abc', 9, function(binaryPath) {

return that.retryBinaryDownload(conf, destParentDir, null, retries, binaryPath);
}
} catch(err) {
console.error('Download failed with error', err);
that.binaryDownloadError('Download failed with error', err.getMessage());
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using err.message instead of err.getMessage(), as standard Error objects do not have a getMessage() method.

Suggested change
that.binaryDownloadError('Download failed with error', err.getMessage());
that.binaryDownloadError('Download failed with error', err.message);

Copilot uses AI. Check for mistakes.

Comment on lines +62 to +63
const binaryDownloadErrorMessage = `Error while trying to execute binary: ${error}`;
console.error(binaryDownloadErrorMessage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if want to show full error with stack else error.message

Suggested change
const binaryDownloadErrorMessage = `Error while trying to execute binary: ${error}`;
console.error(binaryDownloadErrorMessage);
const binaryDownloadErrorMessage = `Error while trying to execute binary: ${util.format(error)}`;
console.error(binaryDownloadErrorMessage);


this.getSourceUrl = function(conf, retries) {
/* Request for an endpoint from Rails no more than twice with 5 retries each */
if (![4, 9].includes(retries) && this.sourceURL != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this check only for 4th and 9th retry?

return this.sourceURL;
}

if (process.env.BINARY_DOWNLOAD_SOURCE_URL !== undefined && process.env.BINARY_DOWNLOAD_FALLBACK_ENABLED == 'true' && this.parentRetries != 4) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

significance of parentRetries != 4?

cmd = 'node';
opts = [path.join(__dirname, 'fetchDownloadSourceUrl.js'), this.key];

if (retries == 4 || (process.env.BINARY_DOWNLOAD_FALLBACK_ENABLED == 'true' && this.parentRetries == 4)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why retries === 4

this.sourceURL = null;
this.downloadErrorMessage = null;

this.getSourceUrl = function(conf, retries) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment above explaining the method


let body = '', data = {'auth_token': authToken};
const options = {
// hostname: 'local.browserstack.com',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants