Fix process not exiting after run, detect closed job listings

- All entry points with log tee now call logStream.end() + process.exit()
  (log stream kept event loop alive, blocking next cron run)
- easy_apply: detect "no longer accepting applications" and similar closed
  listing text before reporting as unsupported

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 12:19:00 -08:00
parent a498f49b95
commit d43e2025b2
4 changed files with 22 additions and 6 deletions

View File

@@ -327,7 +327,9 @@ async function handleResult(job, result, results, settings, profile, apiKey) {
}
}
main().catch(e => {
main().then(() => {
logStream.end(() => process.exit(0));
}).catch(e => {
console.error('Fatal:', e.message);
process.exit(1);
logStream.end(() => process.exit(1));
});

View File

@@ -299,7 +299,9 @@ async function main() {
}
}
main().catch(err => {
main().then(() => {
logStream.end(() => process.exit(0));
}).catch(err => {
console.error('Fatal:', err.message);
process.exit(1);
logStream.end(() => process.exit(1));
});

View File

@@ -248,8 +248,10 @@ async function main() {
return { added: totalAdded, seen: totalSeen };
}
main().catch(e => {
main().then(() => {
logStream.end(() => process.exit(0));
}).catch(e => {
console.error('Fatal:', e.message);
if (e.stack) console.error(e.stack);
process.exit(1);
logStream.end(() => process.exit(1));
});

View File

@@ -163,6 +163,16 @@ export async function apply(page, job, formFiller) {
}
if (!eaBtn) {
// Check if the listing is closed
const closed = await page.evaluate(() => {
const text = (document.body.innerText || '').toLowerCase();
return text.includes('no longer accepting') || text.includes('no longer available') ||
text.includes('this job has expired') || text.includes('job is closed');
}).catch(() => false);
if (closed) {
console.log(` Job closed — no longer accepting applications`);
return { status: 'skipped_no_apply', meta };
}
console.log(` No Easy Apply button found. Page URL: ${page.url()}`);
console.log(` Action: job may have been removed, filled, or changed to external apply`);
return { status: 'skipped_easy_apply_unsupported', meta };