Skip to content

fix(bot): prevent bot freeze by resetting failed init promise#85

Open
Dhereal1 wants to merge 2 commits intoHyperlinksSpace:mainfrom
Dhereal1:fix/start-version-correct
Open

fix(bot): prevent bot freeze by resetting failed init promise#85
Dhereal1 wants to merge 2 commits intoHyperlinksSpace:mainfrom
Dhereal1:fix/start-version-correct

Conversation

@Dhereal1
Copy link
Copy Markdown
Contributor

@Dhereal1 Dhereal1 commented Apr 2, 2026

Problem

If bot.init() failed once (e.g. transient network or config issue), the rejected promise was cached and reused. This caused the bot to stop processing all future updates on that instance.

Fix

  • Reset botInitPromise to null on init failure
  • Allow subsequent requests to retry initialization
  • Preserve single-flight behavior for successful init

Result

  • Bot recovers automatically from transient init failures
  • Prevents “silent dead bot” state

Testing

  • Verified locally with polling mode
  • /start responds correctly
  • Confirmed bot does not stay stuck after init failure

Copy link
Copy Markdown
Member

@staindart staindart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your webhook.ts change, you have both a .catch() and a try/catch block. Since bot.init() returns a Promise, the try/catch is actually redundant because async errors are captured by the .catch() or the returned rejected promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants