Skip to content

Commit ecf6493

Browse files
add sessionId sessionInfo logs in log debugger
1 parent e67c290 commit ecf6493

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/lib/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
7272
startPolling(ctx, capsBuildId, is_baseline, fetchedCapabilitiesResp.projectToken)
7373
}
7474
}
75-
console.log(`fetch caps for sessionId: ${sessionId} are ${JSON.stringify(fetchedCapabilitiesResp)}`)
75+
ctx.log.debug(`fetch caps for sessionId: ${sessionId} are ${JSON.stringify(fetchedCapabilitiesResp)}`)
7676
} catch (error: any) {
7777
// console.log(`Failed to fetch capabilities for sessionId ${sessionId}: ${error.message}`);
7878
}

src/lib/utils.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { promisify } from 'util'
1010
const sleep = promisify(setTimeout);
1111
import { build } from 'tsup';
1212

13-
let isPollingActive = false;
13+
// let isPollingActive = false;
1414
let globalContext: Context;
1515
export const setGlobalContext = (newContext: Context): void => {
1616
globalContext = newContext;
@@ -217,24 +217,31 @@ export function getRenderViewportsForOptions(options: any): Array<Record<string,
217217
}
218218

219219
// Global SIGINT handler
220-
process.on('SIGINT', async () => {
221-
if (isPollingActive) {
222-
console.log('Fetching results interrupted. Exiting...');
223-
isPollingActive = false;
224-
} else {
225-
console.log('\nExiting gracefully...');
226-
}
227-
process.exit(0);
228-
});
220+
// process.on('SIGINT', async () => {
221+
// if (isPollingActive) {
222+
// console.log('Fetching results interrupted. Exiting...');
223+
// isPollingActive = false;
224+
// } else {
225+
// console.log('\nExiting gracefully...');
226+
// }
227+
// process.exit(0);
228+
// });
229229

230230
// Background polling function
231231
export async function startPolling(ctx: Context, build_id: string, baseline: boolean, projectToken: string): Promise<void> {
232+
let filename = '';
233+
let isPollingActive = true;
232234
if (build_id) {
235+
filename = `${build_id}.json`
233236
ctx.log.info(`Fetching results for buildId ${build_id} in progress....`);
234237
} else if (ctx.build && ctx.build.id) {
238+
if (ctx.options.fetchResultsFileName) {
239+
filename = ctx.options.fetchResultsFileName
240+
} else {
241+
filename = `${ctx.build.id}.json`
242+
}
235243
ctx.log.info(`Fetching results for buildId ${ctx.build.id} in progress....`);
236244
}
237-
isPollingActive = true;
238245

239246
const intervalId = setInterval(async () => {
240247
if (!isPollingActive) {
@@ -244,17 +251,10 @@ export async function startPolling(ctx: Context, build_id: string, baseline: boo
244251

245252
try {
246253
let resp;
247-
let filename;
248254
if (build_id) {
249255
resp = await ctx.client.getScreenshotData(build_id, baseline, ctx.log, projectToken);
250-
filename = `${build_id}.json`
251256
} else if (ctx.build && ctx.build.id) {
252257
resp = await ctx.client.getScreenshotData(ctx.build.id, ctx.build.baseline, ctx.log, '');
253-
if (ctx.options.fetchResultsFileName) {
254-
filename = ctx.options.fetchResultsFileName
255-
} else {
256-
filename = `${ctx.build.id}.json`
257-
}
258258
} else {
259259
return;
260260
}

0 commit comments

Comments
 (0)