Skip to content

Commit

Permalink
Merge pull request #334 from LambdaTest/dev
Browse files Browse the repository at this point in the history
Bug fix concurrent download artifact
  • Loading branch information
HRanjan-11 authored Aug 28, 2024
2 parents 94cf03e + 250db8b commit 41fb200
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
17 changes: 11 additions & 6 deletions commands/generate_reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ function download_artefact(
.then((response) => {
response_code = response.status;
resp = response;
response.data.pipe(
fs.createWriteStream(file_path, {
overwrite: true,
})
);
const writer = fs.createWriteStream(file_path, {overwrite: true,});
response.data.pipe(writer);

response.data.on('end', function () {
writer.on('finish', function () {
if (response_code == 200) {
const zip = new StreamZip({ file: file_path });
zip.on("ready", () => {
Expand All @@ -70,13 +67,20 @@ function download_artefact(
}
});

writer.on('error', (err) => {
console.error('Error writing to file:', err);
fs.unlinkSync(file_path); // Cleanup on error
reject('Error writing to file for test id ' + test_id);
});

})
.catch((error) => {

if (error.response) {
resp = error.response
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log("Got error:",error.response);
if (error.response.status == 401) {
resolve("Unauthorized");
} else {
Expand All @@ -95,6 +99,7 @@ function download_artefact(
} else if (error.request) {
console.log(error.cause);
} else {
console.log("Got error:",error.toJSON());
reject(error);
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambdatest-cypress-cli",
"version": "3.0.30",
"version": "3.0.31",
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
"author": "LambdaTest <[email protected]>",
Expand Down

0 comments on commit 41fb200

Please sign in to comment.