Audit fixes: remove dead code, fix run timeout bug, add log tee to all entry points

- Remove unused APPLY_PRIORITY array (replaced by score-based sort)
- Fix run timeout only breaking inner loop — now breaks outer platform loop too
- Remove dead lastProgress variable in easy_apply step loop
- Add stdout/stderr log tee to job_searcher, job_filter, telegram_poller

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 12:13:01 -08:00
parent 9e6b9beb17
commit 51ca354c52
5 changed files with 27 additions and 7 deletions

View File

@@ -36,9 +36,6 @@ const DEFAULT_ENABLED_APPLY_TYPES = ['easy_apply'];
const isPreview = process.argv.includes('--preview');
// Priority order — Easy Apply first, then by ATS volume (data-driven later)
const APPLY_PRIORITY = ['easy_apply', 'wellfound', 'greenhouse', 'lever', 'ashby', 'workday', 'jobvite', 'unknown_external'];
async function main() {
const lock = acquireLock('applier', resolve(__dir, 'data'));
@@ -124,7 +121,9 @@ async function main() {
}
// Process each platform group
let timedOut = false;
for (const [platform, platformJobs] of Object.entries(byPlatform)) {
if (timedOut) break;
console.log(`\n--- ${platform.toUpperCase()} (${platformJobs.length} jobs) ---\n`);
let browser;
try {
@@ -149,6 +148,7 @@ async function main() {
// Check overall run timeout
if (Date.now() - startedAt > APPLY_RUN_TIMEOUT_MS) {
console.log(` ⏱️ Run timeout (${Math.round(APPLY_RUN_TIMEOUT_MS / 60000)}min) — stopping`);
timedOut = true;
break;
}

View File

@@ -19,10 +19,17 @@ loadEnv();
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { readFileSync, writeFileSync, existsSync, unlinkSync } from 'fs';
import { readFileSync, writeFileSync, existsSync, unlinkSync, createWriteStream } from 'fs';
const __dir = dirname(fileURLToPath(import.meta.url));
// Tee all output to a log file so it's always available regardless of how the process is launched
const logStream = createWriteStream(resolve(__dir, 'data/filter.log'), { flags: 'w' });
const origStdoutWrite = process.stdout.write.bind(process.stdout);
const origStderrWrite = process.stderr.write.bind(process.stderr);
process.stdout.write = (chunk, ...args) => { logStream.write(chunk); return origStdoutWrite(chunk, ...args); };
process.stderr.write = (chunk, ...args) => { logStream.write(chunk); return origStderrWrite(chunk, ...args); };
import { getJobsByStatus, updateJobStatus, loadConfig, loadQueue, saveQueue, dedupeAfterFilter } from './lib/queue.mjs';
import { loadProfile, submitBatches, checkBatch, downloadResults } from './lib/filter.mjs';
import { sendTelegram } from './lib/notify.mjs';

View File

@@ -9,9 +9,17 @@ loadEnv(); // load .env before anything else
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { createWriteStream } from 'fs';
const __dir = dirname(fileURLToPath(import.meta.url));
// Tee all output to a log file so it's always available regardless of how the process is launched
const logStream = createWriteStream(resolve(__dir, 'data/searcher.log'), { flags: 'w' });
const origStdoutWrite = process.stdout.write.bind(process.stdout);
const origStderrWrite = process.stderr.write.bind(process.stderr);
process.stdout.write = (chunk, ...args) => { logStream.write(chunk); return origStdoutWrite(chunk, ...args); };
process.stderr.write = (chunk, ...args) => { logStream.write(chunk); return origStderrWrite(chunk, ...args); };
import { addJobs, loadQueue, loadConfig } from './lib/queue.mjs';
import { writeFileSync, readFileSync, existsSync } from 'fs';
import { acquireLock } from './lib/lock.mjs';

View File

@@ -211,7 +211,6 @@ export async function apply(page, job, formFiller) {
}
// Step through modal
let lastProgress = '-1';
let samePageCount = 0;
for (let step = 0; step < LINKEDIN_MAX_MODAL_STEPS; step++) {
const modalStillOpen = await page.$(MODAL);
@@ -297,7 +296,6 @@ export async function apply(page, job, formFiller) {
} else {
samePageCount = 0;
}
lastProgress = newProgress;
continue;
}
@@ -310,7 +308,6 @@ export async function apply(page, job, formFiller) {
console.log(` [step ${step}] clicking Review`);
await reviewBtn.click({ timeout: APPLY_CLICK_TIMEOUT }).catch(() => {});
await page.waitForTimeout(CLICK_WAIT);
lastProgress = progress;
samePageCount = 0;
continue;
}

View File

@@ -10,10 +10,18 @@ loadEnv();
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import { createWriteStream } from 'fs';
import { loadConfig } from './lib/queue.mjs';
import { processTelegramReplies } from './lib/telegram_answers.mjs';
const __dir = dirname(fileURLToPath(import.meta.url));
// Tee all output to a log file
const logStream = createWriteStream(resolve(__dir, 'data/telegram_poller.log'), { flags: 'w' });
const origStdoutWrite = process.stdout.write.bind(process.stdout);
const origStderrWrite = process.stderr.write.bind(process.stderr);
process.stdout.write = (chunk, ...args) => { logStream.write(chunk); return origStdoutWrite(chunk, ...args); };
process.stderr.write = (chunk, ...args) => { logStream.write(chunk); return origStderrWrite(chunk, ...args); };
const settings = loadConfig(resolve(__dir, 'config/settings.json'));
const answersPath = resolve(__dir, 'config/answers.json');