fix: add error logging to applier, session polling, and job card clicks

- job_applier.mjs: stack traces on per-job and browser-level errors
- session.mjs: log pending status and poll count during session refresh
- linkedin.mjs: log warning when job card click fails instead of silent catch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 17:30:24 -08:00
parent ed908c91af
commit 1bf676bb80
3 changed files with 10 additions and 3 deletions

View File

@@ -125,6 +125,7 @@ async function main() {
await handleResult(job, result, results, settings);
} catch (e) {
console.error(` ❌ Error: ${e.message}`);
if (e.stack) console.error(` Stack: ${e.stack.split('\n').slice(1, 3).join(' | ').trim()}`);
const retries = (job.retry_count || 0) + 1;
if (retries <= maxRetries) {
updateJobStatus(job.id, 'new', { retry_count: retries });
@@ -140,6 +141,7 @@ async function main() {
}
} catch (e) {
console.error(` ❌ Browser error for ${platform}: ${e.message}`);
if (e.stack) console.error(` Stack: ${e.stack.split('\n').slice(1, 3).join(' | ').trim()}`);
} finally {
await browser?.browser?.close().catch(() => {});
}

View File

@@ -75,7 +75,9 @@ export async function searchLinkedIn(page, search, { onPage } = {}) {
link?.closest('li')?.click() || link?.click();
}, jobId);
await page.waitForTimeout(CLICK_WAIT);
} catch {}
} catch (e) {
console.warn(` ⚠️ Could not click job card ${jobId}: ${e.message}`);
}
// Read title, company, location from detail panel (more accurate)
const meta = await page.evaluate(({ id, track, excludes }) => {

View File

@@ -25,16 +25,19 @@ export async function refreshSession(platform, apiKey, connectionIds = {}) {
}
// If not immediately successful, poll for up to 30s
console.log(`${platform} session pending (status: ${loginResp.status}), polling...`);
const start = Date.now();
let pollCount = 0;
while (Date.now() - start < 30000) {
await new Promise(r => setTimeout(r, 2000));
pollCount++;
const conn = await kernel.auth.connections.retrieve(connectionId);
if (conn.status === 'SUCCESS') {
console.log(`${platform} session refreshed`);
console.log(`${platform} session refreshed (after ${pollCount} polls)`);
return true;
}
if (['FAILED', 'EXPIRED', 'CANCELED'].includes(conn.status)) {
console.warn(` ⚠️ ${platform} session refresh failed: ${conn.status}`);
console.warn(` ⚠️ ${platform} session refresh failed: ${conn.status} (after ${pollCount} polls)`);
return false;
}
}