fix: audit bugs + better error logging for searcher debugging

Bugs fixed:
- form_filler.mjs: add missing await on el.evaluate() in getLabel()
- analyze_ats.mjs: check job.apply_type instead of non-existent job.easy_apply
- status.mjs: fix typo "that run" → "in that run"
- README: add missing lock.mjs to project structure

Logging improvements:
- job_searcher.mjs: log browser creation, login steps, stack traces on error
- linkedin.mjs/wellfound.mjs: catch and log navigation failures per keyword
- browser.mjs: descriptive errors for Kernel and CDP connection failures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 17:28:23 -08:00
parent ec68e621b8
commit ed908c91af
8 changed files with 35 additions and 7 deletions

View File

@@ -168,6 +168,7 @@ claw-apply/
│ ├── linkedin.mjs LinkedIn search + job classification │ ├── linkedin.mjs LinkedIn search + job classification
│ ├── wellfound.mjs Wellfound search │ ├── wellfound.mjs Wellfound search
│ ├── queue.mjs Job queue and config management │ ├── queue.mjs Job queue and config management
│ ├── lock.mjs Process lock to prevent parallel runs
│ ├── notify.mjs Telegram notifications with rate limiting │ ├── notify.mjs Telegram notifications with rate limiting
│ └── apply/ │ └── apply/
│ ├── index.mjs Apply handler registry │ ├── index.mjs Apply handler registry

View File

@@ -57,7 +57,7 @@ function analyze() {
} }
default: default:
// Count easy apply eligible (status=new on linkedin with easy apply available) // Count easy apply eligible (status=new on linkedin with easy apply available)
if (job.status === 'new' && job.easy_apply) easyApply++; if (job.status === 'new' && job.apply_type === 'easy_apply') easyApply++;
} }
} }

View File

@@ -96,7 +96,9 @@ async function main() {
console.log('🔗 LinkedIn search...'); console.log('🔗 LinkedIn search...');
let liBrowser; let liBrowser;
try { try {
console.log(' Creating browser...');
liBrowser = await createBrowser(settings, 'linkedin'); liBrowser = await createBrowser(settings, 'linkedin');
console.log(' Browser connected, verifying login...');
const loggedIn = await ensureLoggedIn(liBrowser.page, liLogin, 'linkedin', settings.kernel_api_key || process.env.KERNEL_API_KEY, settings.kernel?.connection_ids || {}); const loggedIn = await ensureLoggedIn(liBrowser.page, liLogin, 'linkedin', settings.kernel_api_key || process.env.KERNEL_API_KEY, settings.kernel?.connection_ids || {});
if (!loggedIn) throw new Error('LinkedIn not logged in'); if (!loggedIn) throw new Error('LinkedIn not logged in');
console.log(' ✅ Logged in'); console.log(' ✅ Logged in');
@@ -125,6 +127,7 @@ async function main() {
platformsRun.push('LinkedIn'); platformsRun.push('LinkedIn');
} catch (e) { } catch (e) {
console.error(` ❌ LinkedIn error: ${e.message}`); console.error(` ❌ LinkedIn error: ${e.message}`);
if (e.stack) console.error(` Stack: ${e.stack.split('\n').slice(1, 3).join(' | ').trim()}`);
} finally { } finally {
await liBrowser?.browser?.close().catch(() => {}); await liBrowser?.browser?.close().catch(() => {});
} }
@@ -135,7 +138,9 @@ async function main() {
console.log('\n🌐 Wellfound search...'); console.log('\n🌐 Wellfound search...');
let wfBrowser; let wfBrowser;
try { try {
console.log(' Creating browser...');
wfBrowser = await createBrowser(settings, 'wellfound'); wfBrowser = await createBrowser(settings, 'wellfound');
console.log(' Browser connected, verifying login...');
const loggedIn = await ensureLoggedIn(wfBrowser.page, wfLogin, 'wellfound', settings.kernel_api_key || process.env.KERNEL_API_KEY, settings.kernel?.connection_ids || {}); const loggedIn = await ensureLoggedIn(wfBrowser.page, wfLogin, 'wellfound', settings.kernel_api_key || process.env.KERNEL_API_KEY, settings.kernel?.connection_ids || {});
if (!loggedIn) console.warn(' ⚠️ Wellfound login unconfirmed, proceeding'); if (!loggedIn) console.warn(' ⚠️ Wellfound login unconfirmed, proceeding');
else console.log(' ✅ Logged in'); else console.log(' ✅ Logged in');
@@ -164,6 +169,7 @@ async function main() {
platformsRun.push('Wellfound'); platformsRun.push('Wellfound');
} catch (e) { } catch (e) {
console.error(` ❌ Wellfound error: ${e.message}`); console.error(` ❌ Wellfound error: ${e.message}`);
if (e.stack) console.error(` Stack: ${e.stack.split('\n').slice(1, 3).join(' | ').trim()}`);
} finally { } finally {
await wfBrowser?.browser?.close().catch(() => {}); await wfBrowser?.browser?.close().catch(() => {});
} }
@@ -182,5 +188,6 @@ async function main() {
main().catch(e => { main().catch(e => {
console.error('Fatal:', e.message); console.error('Fatal:', e.message);
if (e.stack) console.error(e.stack);
process.exit(1); process.exit(1);
}); });

View File

@@ -38,9 +38,19 @@ export async function createBrowser(settings, profileKey) {
if (profileName) opts.profile = { name: profileName }; if (profileName) opts.profile = { name: profileName };
if (kernelConfig.proxy_id) opts.proxy = { id: kernelConfig.proxy_id }; if (kernelConfig.proxy_id) opts.proxy = { id: kernelConfig.proxy_id };
const kb = await kernel.browsers.create(opts); let kb;
try {
kb = await kernel.browsers.create(opts);
} catch (e) {
throw new Error(`Kernel browser creation failed: ${e.message}`);
}
const pw = await getChromium(playwrightPath); const pw = await getChromium(playwrightPath);
const browser = await pw.connectOverCDP(kb.cdp_ws_url); let browser;
try {
browser = await pw.connectOverCDP(kb.cdp_ws_url);
} catch (e) {
throw new Error(`CDP connection failed (browser ${kb.id}): ${e.message}`);
}
const ctx = browser.contexts()[0] || await browser.newContext(); const ctx = browser.contexts()[0] || await browser.newContext();
const page = ctx.pages()[0] || await ctx.newPage(); const page = ctx.pages()[0] || await ctx.newPage();

View File

@@ -107,7 +107,7 @@ export class FormFiller {
} }
async getLabel(el) { async getLabel(el) {
return el.evaluate(node => { return await el.evaluate(node => {
const id = node.id; const id = node.id;
const forLabel = id ? document.querySelector(`label[for="${id}"]`)?.textContent?.trim() : ''; const forLabel = id ? document.querySelector(`label[for="${id}"]`)?.textContent?.trim() : '';
const ariaLabel = node.getAttribute('aria-label') || ''; const ariaLabel = node.getAttribute('aria-label') || '';

View File

@@ -40,7 +40,12 @@ export async function searchLinkedIn(page, search, { onPage } = {}) {
} }
const url = `${LINKEDIN_BASE}/jobs/search/?${params.toString()}`; const url = `${LINKEDIN_BASE}/jobs/search/?${params.toString()}`;
try {
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: NAVIGATION_TIMEOUT }); await page.goto(url, { waitUntil: 'domcontentloaded', timeout: NAVIGATION_TIMEOUT });
} catch (e) {
console.error(` ⚠️ Navigation failed for "${keyword}": ${e.message}`);
continue;
}
await page.waitForTimeout(PAGE_LOAD_WAIT); await page.waitForTimeout(PAGE_LOAD_WAIT);
let pageNum = 0; let pageNum = 0;

View File

@@ -23,7 +23,12 @@ export async function searchWellfound(page, search, { onPage } = {}) {
for (const keyword of search.keywords) { for (const keyword of search.keywords) {
const url = `${WELLFOUND_BASE}/jobs?q=${encodeURIComponent(keyword)}&remote=true`; const url = `${WELLFOUND_BASE}/jobs?q=${encodeURIComponent(keyword)}&remote=true`;
try {
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: SEARCH_NAVIGATION_TIMEOUT }); await page.goto(url, { waitUntil: 'domcontentloaded', timeout: SEARCH_NAVIGATION_TIMEOUT });
} catch (e) {
console.error(` ⚠️ Navigation failed for "${keyword}": ${e.message}`);
continue;
}
await page.waitForTimeout(SEARCH_LOAD_WAIT); await page.waitForTimeout(SEARCH_LOAD_WAIT);
// Scroll to bottom repeatedly to trigger infinite scroll // Scroll to bottom repeatedly to trigger infinite scroll

View File

@@ -127,7 +127,7 @@ function formatReport(s) {
? `🔄 Running now` ? `🔄 Running now`
: `⏸️ Last ran ${timeAgo(ar.last_run?.finished_at)}`; : `⏸️ Last ran ${timeAgo(ar.last_run?.finished_at)}`;
const lastApplierDetail = ar.last_run && !ar.running const lastApplierDetail = ar.last_run && !ar.running
? ` Applied ${ar.last_run.submitted} jobs that run` ? ` Applied ${ar.last_run.submitted} jobs in that run`
: null; : null;
const lines = [ const lines = [