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:
@@ -36,9 +36,6 @@ const DEFAULT_ENABLED_APPLY_TYPES = ['easy_apply'];
|
|||||||
|
|
||||||
const isPreview = process.argv.includes('--preview');
|
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() {
|
async function main() {
|
||||||
const lock = acquireLock('applier', resolve(__dir, 'data'));
|
const lock = acquireLock('applier', resolve(__dir, 'data'));
|
||||||
|
|
||||||
@@ -124,7 +121,9 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process each platform group
|
// Process each platform group
|
||||||
|
let timedOut = false;
|
||||||
for (const [platform, platformJobs] of Object.entries(byPlatform)) {
|
for (const [platform, platformJobs] of Object.entries(byPlatform)) {
|
||||||
|
if (timedOut) break;
|
||||||
console.log(`\n--- ${platform.toUpperCase()} (${platformJobs.length} jobs) ---\n`);
|
console.log(`\n--- ${platform.toUpperCase()} (${platformJobs.length} jobs) ---\n`);
|
||||||
let browser;
|
let browser;
|
||||||
try {
|
try {
|
||||||
@@ -149,6 +148,7 @@ async function main() {
|
|||||||
// Check overall run timeout
|
// Check overall run timeout
|
||||||
if (Date.now() - startedAt > APPLY_RUN_TIMEOUT_MS) {
|
if (Date.now() - startedAt > APPLY_RUN_TIMEOUT_MS) {
|
||||||
console.log(` ⏱️ Run timeout (${Math.round(APPLY_RUN_TIMEOUT_MS / 60000)}min) — stopping`);
|
console.log(` ⏱️ Run timeout (${Math.round(APPLY_RUN_TIMEOUT_MS / 60000)}min) — stopping`);
|
||||||
|
timedOut = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,17 @@ loadEnv();
|
|||||||
|
|
||||||
import { dirname, resolve } from 'path';
|
import { dirname, resolve } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
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));
|
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 { getJobsByStatus, updateJobStatus, loadConfig, loadQueue, saveQueue, dedupeAfterFilter } from './lib/queue.mjs';
|
||||||
import { loadProfile, submitBatches, checkBatch, downloadResults } from './lib/filter.mjs';
|
import { loadProfile, submitBatches, checkBatch, downloadResults } from './lib/filter.mjs';
|
||||||
import { sendTelegram } from './lib/notify.mjs';
|
import { sendTelegram } from './lib/notify.mjs';
|
||||||
|
|||||||
@@ -9,9 +9,17 @@ loadEnv(); // load .env before anything else
|
|||||||
|
|
||||||
import { dirname, resolve } from 'path';
|
import { dirname, resolve } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { createWriteStream } from 'fs';
|
||||||
|
|
||||||
const __dir = dirname(fileURLToPath(import.meta.url));
|
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 { addJobs, loadQueue, loadConfig } from './lib/queue.mjs';
|
||||||
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
||||||
import { acquireLock } from './lib/lock.mjs';
|
import { acquireLock } from './lib/lock.mjs';
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ export async function apply(page, job, formFiller) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step through modal
|
// Step through modal
|
||||||
let lastProgress = '-1';
|
|
||||||
let samePageCount = 0;
|
let samePageCount = 0;
|
||||||
for (let step = 0; step < LINKEDIN_MAX_MODAL_STEPS; step++) {
|
for (let step = 0; step < LINKEDIN_MAX_MODAL_STEPS; step++) {
|
||||||
const modalStillOpen = await page.$(MODAL);
|
const modalStillOpen = await page.$(MODAL);
|
||||||
@@ -297,7 +296,6 @@ export async function apply(page, job, formFiller) {
|
|||||||
} else {
|
} else {
|
||||||
samePageCount = 0;
|
samePageCount = 0;
|
||||||
}
|
}
|
||||||
lastProgress = newProgress;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +308,6 @@ export async function apply(page, job, formFiller) {
|
|||||||
console.log(` [step ${step}] clicking Review`);
|
console.log(` [step ${step}] clicking Review`);
|
||||||
await reviewBtn.click({ timeout: APPLY_CLICK_TIMEOUT }).catch(() => {});
|
await reviewBtn.click({ timeout: APPLY_CLICK_TIMEOUT }).catch(() => {});
|
||||||
await page.waitForTimeout(CLICK_WAIT);
|
await page.waitForTimeout(CLICK_WAIT);
|
||||||
lastProgress = progress;
|
|
||||||
samePageCount = 0;
|
samePageCount = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,18 @@ loadEnv();
|
|||||||
|
|
||||||
import { resolve, dirname } from 'path';
|
import { resolve, dirname } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { createWriteStream } from 'fs';
|
||||||
import { loadConfig } from './lib/queue.mjs';
|
import { loadConfig } from './lib/queue.mjs';
|
||||||
import { processTelegramReplies } from './lib/telegram_answers.mjs';
|
import { processTelegramReplies } from './lib/telegram_answers.mjs';
|
||||||
|
|
||||||
const __dir = dirname(fileURLToPath(import.meta.url));
|
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 settings = loadConfig(resolve(__dir, 'config/settings.json'));
|
||||||
const answersPath = resolve(__dir, 'config/answers.json');
|
const answersPath = resolve(__dir, 'config/answers.json');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user