From 334d688b50e38780d09c6dd8f5f43ec5e5aa4db8 Mon Sep 17 00:00:00 2001 From: Nasyarobby Putra Date: Sun, 13 Sep 2026 23:12:37 +0700 Subject: [PATCH] fix(watcher): force IPv4 for PM2 and widen process-messages defaults Avoid Gmail hang on rpi4 broken IPv6 Happy Eyeballs, and default backfill to 30d inbox / max 500. Co-authored-by: Cursor --- AGENTS.md | 2 +- apps/watcher/ecosystem.config.cjs | 3 +++ apps/watcher/scripts/process-messages.js | 9 ++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 12da9d4..7774a0d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -82,7 +82,7 @@ Gmail Date on a forward is “today”; `trx_date` still comes from the receipt npm run list-messages -- npm run list-messages -- --query 'newer_than:14d has:attachment filename:eml' --max 100 -# Dry-run recent Livin/Grab subjects (default query: newer_than:7d) +# Dry-run last 30 days of inbox (default query: in:inbox newer_than:30d) npm run process-messages -- --dry-run # Process a wrapper mail that has .eml attachments diff --git a/apps/watcher/ecosystem.config.cjs b/apps/watcher/ecosystem.config.cjs index 29f7ee9..394918d 100644 --- a/apps/watcher/ecosystem.config.cjs +++ b/apps/watcher/ecosystem.config.cjs @@ -22,6 +22,9 @@ module.exports = { env: { NODE_ENV: "production", WATCHER_PORT: "8083", + // Pi has broken global IPv6 (SYN-SENT via link-local); Happy Eyeballs hangs Gmail calls. + NODE_OPTIONS: + "--dns-result-order=ipv4first --no-network-family-autoselection", }, }, ], diff --git a/apps/watcher/scripts/process-messages.js b/apps/watcher/scripts/process-messages.js index 21e43cb..7aab839 100644 --- a/apps/watcher/scripts/process-messages.js +++ b/apps/watcher/scripts/process-messages.js @@ -14,10 +14,10 @@ * npm run process-messages -w watcher -- --dry-run --max 20 * * Options: - * --query Gmail search (default targets Livin/Grab subjects, newer_than:7d) + * --query Gmail search (default: in:inbox newer_than:30d) * --ids Explicit message IDs (skips list search) * --user Mailbox to use (default: first user with tokens) - * --max Max messages to process (default 50) + * --max Max messages to process (default 500) * --dry-run Parse and log only; do not write PocketBase */ @@ -36,15 +36,14 @@ import { runPipeline } from "../src/pipeline.js"; import { processFetchedMessage } from "../src/process-fetched.js"; import { pocketbaseConfigured } from "../src/pocketbase/client.js"; -const DEFAULT_QUERY = - 'newer_than:7d (subject:"Pembayaran Berhasil!" OR subject:"Your Grab E-Receipt" OR subject:"Pemindahan Dana Sesama Rekening BRI")'; +const DEFAULT_QUERY = "in:inbox newer_than:30d"; function parseArgs(argv) { const out = { query: null, ids: [], user: null, - max: 50, + max: 500, dryRun: false, help: false, };