Closed skyward tab for mem
This commit is contained in:
19
index.ts
19
index.ts
@@ -541,6 +541,8 @@ async function loginToSkyward(page: Page, username: string, password: string, co
|
||||
}
|
||||
|
||||
async function openSkywardFromLaunchpad(page: Page, context: any, allClassGrades: any[]) {
|
||||
let newPage: Page | null = null;
|
||||
|
||||
try {
|
||||
logger.info('Step 6: Searching for Skyward app...');
|
||||
|
||||
@@ -585,9 +587,9 @@ async function openSkywardFromLaunchpad(page: Page, context: any, allClassGrades
|
||||
logger.info('Step 7: Pressing Enter to select Skyward...');
|
||||
|
||||
const newPagePromise = new Promise<Page>((resolve) => {
|
||||
context.once('page', async (newPage: Page) => {
|
||||
logger.info(`New tab opened with URL: ${newPage.url()}`);
|
||||
resolve(newPage);
|
||||
context.once('page', async (np: Page) => {
|
||||
logger.info(`New tab opened with URL: ${np.url()}`);
|
||||
resolve(np);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -595,7 +597,7 @@ async function openSkywardFromLaunchpad(page: Page, context: any, allClassGrades
|
||||
logger.info('✓ Pressed Enter');
|
||||
|
||||
logger.info('Waiting for new tab to open...');
|
||||
const newPage = await Promise.race([
|
||||
newPage = await Promise.race([
|
||||
newPagePromise,
|
||||
page.waitForTimeout(10000).then(() => null),
|
||||
]);
|
||||
@@ -625,9 +627,18 @@ async function openSkywardFromLaunchpad(page: Page, context: any, allClassGrades
|
||||
const errorMsg = error instanceof Error ? error.message : String(error);
|
||||
logger.error(`Error opening Skyward from launchpad: ${errorMsg}`);
|
||||
throw error;
|
||||
} finally {
|
||||
// Always close the Skyward tab to prevent resource leaks
|
||||
if (newPage && !newPage.isClosed()) {
|
||||
await newPage.close().catch((err) =>
|
||||
logger.warn('Error closing Skyward tab:', err)
|
||||
);
|
||||
logger.info('Closed Skyward tab');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function navigateToGrading(page: Page, allClassGrades: any[]) {
|
||||
logger.info('Step 8: Navigating to Grading section...');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user