From d43e2025b2c36a6465d2d5111a489d34c7a6d09c Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Fri, 6 Mar 2026 12:19:00 -0800 Subject: [PATCH] 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 --- job_applier.mjs | 6 ++++-- job_filter.mjs | 6 ++++-- job_searcher.mjs | 6 ++++-- lib/apply/easy_apply.mjs | 10 ++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/job_applier.mjs b/job_applier.mjs index a349316..df1b9c0 100644 --- a/job_applier.mjs +++ b/job_applier.mjs @@ -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)); }); diff --git a/job_filter.mjs b/job_filter.mjs index b7fb208..9342390 100644 --- a/job_filter.mjs +++ b/job_filter.mjs @@ -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)); }); diff --git a/job_searcher.mjs b/job_searcher.mjs index 318b9f5..0468c15 100644 --- a/job_searcher.mjs +++ b/job_searcher.mjs @@ -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)); }); diff --git a/lib/apply/easy_apply.mjs b/lib/apply/easy_apply.mjs index fe28d34..1fb8049 100644 --- a/lib/apply/easy_apply.mjs +++ b/lib/apply/easy_apply.mjs @@ -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 };