fix(bot): silence "Aborted delay" polling log on Ctrl+C shutdown#464
fix(bot): silence "Aborted delay" polling log on Ctrl+C shutdown#464xlabtg merged 3 commits intoxlabtg:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#460
Grammy's bot.stop() aborts the polling loop's pending delay via AbortController. The error surfaces as a rejected bot.start() promise and was logged as "[Bot] Polling error", confusing users who simply stopped the agent — especially noticeable with MTProxy enabled where the shutdown path is slower. DealBot now tracks a `stopping` flag set by stop() and skips the error log when the rejection arrives during shutdown. Real polling failures during normal operation continue to be logged. Closes xlabtg#460
Solution summaryBoth CI runs passed. Summary: Root cause: Grammy's Fix (commit 024d1a1):
Verification: lint clean, typecheck clean, format clean, full suite 3498/3498 passing, both upstream CI runs green. PR: #464 (now ready for review). This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $3.207598📊 Context and tokens usage:
Total: (90.3K + 4.3M cached) input tokens, 19.3K output tokens, $3.207599 cost 🤖 Models used:
📎 Log file uploaded as Gist (1701KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit 8a0b92a.
Summary
When the agent is stopped (Ctrl+C), Grammy's
bot.stop()aborts the polling loop's pending long-poll delay through anAbortController. The resulting rejection surfaces inDealBot.start()'s.catch(...)handler and was being logged as:This is misleading — it looks like a real failure but is just Grammy's normal shutdown signal. The annoyance was especially visible on the MTProxy path, where the shutdown sequence is slower.
This PR adds a
stoppingflag toDealBotthat is set insidestop(). The.catchhandler instart()now suppresses the log when the rejection arrives during shutdown. Real polling failures during normal operation continue to be logged.Changes
src/bot/index.ts: trackstoppingand skip the[Bot] Polling errorlog when the rejection arrives during a shutdown.src/bot/__tests__/deal-bot-shutdown.test.ts(new): regression tests covering both the suppressed-during-shutdown case and the still-logged-during-runtime case.CHANGELOG.md: note under[Unreleased] / Fixed.package.json: bump to0.8.17.How to reproduce (before this PR)
mtproto.enabled: truewith at least one proxy.npm start, wait for[Bot] @… polling started.ERROR: [Bot] Polling error … Aborted delayfollowed (afterSHUTDOWN_TIMEOUT_MS) byShutdown timed out, forcing exit.After this PR, the
Polling errorline is gone — stopping is silent on the polling channel.Test plan
npm run lint— no errorsnpm run typecheck— no errorsnpm test— 3498/3498 passing, including the two new shutdown tests insrc/bot/__tests__/deal-bot-shutdown.test.tsnpm run format:check— clean[Bot] Polling error … Aborted delayline appearsFixes #460