Skip to content

Commit 41fb200

Browse files
authored
Merge pull request #334 from LambdaTest/dev
Bug fix concurrent download artifact
2 parents 94cf03e + 250db8b commit 41fb200

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

commands/generate_reports.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@ function download_artefact(
4747
.then((response) => {
4848
response_code = response.status;
4949
resp = response;
50-
response.data.pipe(
51-
fs.createWriteStream(file_path, {
52-
overwrite: true,
53-
})
54-
);
50+
const writer = fs.createWriteStream(file_path, {overwrite: true,});
51+
response.data.pipe(writer);
5552

56-
response.data.on('end', function () {
53+
writer.on('finish', function () {
5754
if (response_code == 200) {
5855
const zip = new StreamZip({ file: file_path });
5956
zip.on("ready", () => {
@@ -70,13 +67,20 @@ function download_artefact(
7067
}
7168
});
7269

70+
writer.on('error', (err) => {
71+
console.error('Error writing to file:', err);
72+
fs.unlinkSync(file_path); // Cleanup on error
73+
reject('Error writing to file for test id ' + test_id);
74+
});
75+
7376
})
7477
.catch((error) => {
7578

7679
if (error.response) {
7780
resp = error.response
7881
// The request was made and the server responded with a status code
7982
// that falls out of the range of 2xx
83+
console.log("Got error:",error.response);
8084
if (error.response.status == 401) {
8185
resolve("Unauthorized");
8286
} else {
@@ -95,6 +99,7 @@ function download_artefact(
9599
} else if (error.request) {
96100
console.log(error.cause);
97101
} else {
102+
console.log("Got error:",error.toJSON());
98103
reject(error);
99104
}
100105

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambdatest-cypress-cli",
3-
"version": "3.0.30",
3+
"version": "3.0.31",
44
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
55
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
66
"author": "LambdaTest <[email protected]>",

0 commit comments

Comments
 (0)