Skip to content

Commit b310be1

Browse files
committed
refactor: comment out console error and log statements in context.ts and dialogs.ts
- Commented out various console log and error statements in context.ts to reduce noise during execution. - Updated dialog handling in dialogs.ts by commenting out the error logging to streamline the process.
1 parent 2ffef4d commit b310be1

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/context.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,22 @@ ${code.join('\n')}
319319
try {
320320
await download.saveAs(entry.outputFile);
321321
} catch (error) {
322-
console.warn('Error saving download:', error);
322+
// console.warn('Error saving download:', error);
323323
} finally {
324324
entry.finished = true;
325325
}
326326
}
327327

328328
private async _onPageCreated(page: playwright.Page) {
329-
console.log('Page created, checking for popup');
329+
// console.log('Page created, checking for popup');
330330

331331
try {
332332
const isPopup = await this._handlePopup(page);
333333
// If it was a popup, we don't want to add it to the tabs list
334334
if (isPopup)
335335
return;
336336
} catch (error) {
337-
console.error('Error handling popup:', error);
337+
// console.error('Error handling popup:', error);
338338
// Continue with normal page creation even if popup handling fails
339339
}
340340

@@ -356,13 +356,13 @@ ${code.join('\n')}
356356
// Check if this is actually a popup window (not just a new tab)
357357
const isPopupWindow = await this._isPopupWindow(popupPage);
358358
if (!isPopupWindow) {
359-
console.log('Not a popup window');
359+
// console.log('Not a popup window');
360360
// If it's not a popup window, we don't need to do anything, since
361361
// the context.on("page") event will handle it.
362362
return false;
363363
}
364364

365-
console.log('Is a popup window, getting URL');
365+
// console.log('Is a popup window, getting URL');
366366

367367
await popupPage.waitForLoadState('domcontentloaded');
368368

@@ -380,15 +380,15 @@ ${code.join('\n')}
380380
popupUrl = undefined;
381381

382382
} catch (error) {
383-
console.log('Failed to get popup URL, retrying');
383+
// console.log('Failed to get popup URL, retrying');
384384
}
385385

386386
await new Promise(resolve => setTimeout(resolve, 1000));
387387
attempts++;
388388
}
389389

390390
if (!popupUrl) {
391-
console.log('Failed to get popup URL, closing popup');
391+
// console.log('Failed to get popup URL, closing popup');
392392
await popupPage.close();
393393
return true;
394394
}
@@ -416,7 +416,7 @@ ${code.join('\n')}
416416
} catch (navigationError) {
417417
// If navigation fails, just close the popup and keep the new page
418418
// The new page will remain open but empty, which is better than losing it
419-
console.warn('Navigation to popup URL failed:', navigationError);
419+
// console.warn('Navigation to popup URL failed:', navigationError);
420420
}
421421

422422
// Close the popup
@@ -427,7 +427,7 @@ ${code.join('\n')}
427427
await popupPage.close();
428428
} catch (closeError) {
429429
// Ignore close errors
430-
console.warn('Error closing popup:', closeError);
430+
// console.warn('Error closing popup:', closeError);
431431
}
432432
}
433433

@@ -450,20 +450,20 @@ ${code.join('\n')}
450450
),
451451
]);
452452

453-
console.log('Popup analysis:', analysis);
453+
// console.log('Popup analysis:', analysis);
454454

455455
if (analysis.isPopup) {
456-
console.log(`Popup detected with ${analysis.confidence}% confidence`);
457-
console.log('Reasons:', analysis.reasons);
456+
// console.log(`Popup detected with ${analysis.confidence}% confidence`);
457+
// console.log('Reasons:', analysis.reasons);
458458
}
459459

460460
return analysis.isPopup;
461461
} catch (error) {
462462
// Check if it's a navigation-related error
463-
const errorMessage =
464-
error instanceof Error ? error.message : String(error);
463+
// const errorMessage =
464+
// error instanceof Error ? error.message : String(error);
465465

466-
console.error('Error checking if page is a popup window:', errorMessage);
466+
// console.error('Error checking if page is a popup window:', errorMessage);
467467
// If we can't determine, assume it's not a popup window
468468
return false;
469469
}
@@ -479,12 +479,12 @@ ${code.join('\n')}
479479
if (this._currentTab === tab)
480480
this._currentTab = this._tabs[Math.min(index, this._tabs.length - 1)];
481481
if (!this._tabs.length) {
482-
console.log('No tabs left, closing context');
482+
// console.log('No tabs left, closing context');
483483

484484
// Note that its likely here that the context is already dead :(
485485
// so we wrap this in a try catch
486486
this.close().catch(error => {
487-
console.error('Error closing context:', error);
487+
// console.error('Error closing context:', error);
488488
});
489489
}
490490
}

src/tools/dialogs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const handleDialog: ToolFactory = captureSnapshot => defineTool({
4545
await dialogState.dialog.dismiss();
4646
break;
4747
} catch (error) {
48-
console.error(error);
48+
// console.error(error);
4949
attempt++;
5050
}
5151
}

0 commit comments

Comments
 (0)