From 164a9b4920ef97aca51fa087df684924d950a28d Mon Sep 17 00:00:00 2001 From: SatoshiQaziMuhammed Date: Wed, 5 Aug 2026 14:16:26 -0700 Subject: [PATCH] fix(noter): use the fs import instead of require in the heartbeat helpers (#3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This module is ESM, so `require` is not defined at runtime. `node --check` only parses, so it passed while both helpers would have thrown: the write was swallowed by its catch, and the read fell through to `Infinity`, which the watchdog reads as a permanently stale heartbeat — it would have exited the process a minute after every scan and left the bot restarting in a loop. `fs` is already imported at the top of the file; use it. --- noter/bot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noter/bot.js b/noter/bot.js index bae1bae..a8d86e0 100644 --- a/noter/bot.js +++ b/noter/bot.js @@ -52,7 +52,7 @@ const STALE_AFTER = SCAN_INTERVAL * 3; function touchHeartbeat() { try { - require('fs').writeFileSync(HEARTBEAT_FILE, String(Date.now())); + fs.writeFileSync(HEARTBEAT_FILE, String(Date.now())); } catch (err) { log('WARN', 'Could not write heartbeat', { error: err.message }); } @@ -62,7 +62,7 @@ function touchHeartbeat() { /// yet — an unwritable or missing heartbeat counts as stale rather than healthy. function heartbeatAge() { try { - const t = Number(require('fs').readFileSync(HEARTBEAT_FILE, 'utf8')); + const t = Number(fs.readFileSync(HEARTBEAT_FILE, 'utf8')); return Number.isFinite(t) ? Date.now() - t : Infinity; } catch { return Infinity;