-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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.
that.binaryDownloadError('Download failed with error', err.getMessage()); | |
that.binaryDownloadError('Download failed with error', err.message); |
Copilot uses AI. Check for mistakes.
const binaryDownloadErrorMessage = `Error while trying to execute binary: ${error}`; | ||
console.error(binaryDownloadErrorMessage); |
There was a problem hiding this comment.
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
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
No description provided.