Skip to content

Commit 3c3e34c

Browse files
address comment reviews
1 parent 44d290c commit 3c3e34c

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/lib/httpClient.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ export default class httpClient {
102102
headers: resp.headers,
103103
body: resp.data
104104
})}`)
105-
return resp.data;
105+
if (resp.data !== ""){
106+
return resp.data;
107+
} else {
108+
return resp;
109+
}
106110
} else {
107111
log.debug(`empty response: ${JSON.stringify(resp)}`)
108112
return {};

src/lib/snapshotQueue.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,24 @@ export default class Queue {
357357
const presignedResponse = await this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
358358
const uploadUrl = presignedResponse.data.url;
359359

360-
await this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot)
361-
await this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
360+
let snapshotUploadResponse = await this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
361+
if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
362+
this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
363+
this.processedSnapshots.push({ name: snapshot?.name, error: `snapshot failed; Unable to upload dom to S3` });
364+
if (this.ctx.browser) {
365+
for (let context of this.ctx.browser.contexts()) {
366+
for (let page of context.pages()) {
367+
await page.close();
368+
this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
369+
}
370+
await context.close();
371+
this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
372+
}
373+
}
374+
this.processNext();
375+
} else {
376+
await this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
377+
}
362378
} else {
363379
await this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
364380
}

src/tasks/createBuildExec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
2121
}
2222
if (ctx.build.id === '') {
2323
ctx.log.debug('Build creation failed: Build ID is empty');
24-
task.output = chalk.gray('Build creation failed: Build ID is empty');
24+
task.output = chalk.red('Build creation failed: Build ID is empty');
2525
throw new Error('SmartUI build creation failed');
2626
}
2727
task.output = chalk.gray(`build id: ${resp.data.buildId}`);
@@ -44,9 +44,9 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
4444
} else if (tunnelResp && tunnelResp.error) {
4545
if (tunnelResp.error.message) {
4646
if (tunnelResp.error.code && tunnelResp.error.code === 400) {
47-
ctx.log.info(chalk.yellow(tunnelResp.error.message))
47+
ctx.log.warn(tunnelResp.error.message)
4848
} else {
49-
ctx.log.info(chalk.yellow(`Error while fetch tunnel details; Either tunnel is not running or tunnel parameters are different`))
49+
ctx.log.warn(`Error while fetch tunnel details; Either tunnel is not running or tunnel parameters are different`)
5050
}
5151
}
5252
}

0 commit comments

Comments
 (0)