fix(telegram): webhook hang - tests and fix#26933
Merged
Takhoffman merged 11 commits intoopenclaw:mainfrom Feb 26, 2026
Merged
Conversation
30ae10d to
0fce4e2
Compare
0fce4e2 to
67312c9
Compare
Contributor
|
PR #26933 - fix(telegram): webhook hang - tests and fix (#26933) Merged via squash.
Thanks @huntharo! |
We have released the patch for grammY. If you use v1.40.1, this no longer happens. |
2 tasks
execute008
pushed a commit
to execute008/openclaw
that referenced
this pull request
Feb 27, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
r4jiv007
pushed a commit
to r4jiv007/openclaw
that referenced
this pull request
Feb 28, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
vincentkoc
pushed a commit
to Sid-Qin/openclaw
that referenced
this pull request
Feb 28, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
vincentkoc
pushed a commit
to rylena/rylen-openclaw
that referenced
this pull request
Feb 28, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
steipete
pushed a commit
to Sid-Qin/openclaw
that referenced
this pull request
Mar 2, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
dorgonman
pushed a commit
to kanohorizonia/openclaw
that referenced
this pull request
Mar 3, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
thebenjaminlee
pushed a commit
to escape-velocity-ventures/openclaw
that referenced
this pull request
Mar 7, 2026
…huntharo Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Describe the problem and fix in 2–5 bullets:
webhookbutpollingwas not impacted.webhookCallback(..., "callback"), pre-initialized bot startup, read request JSON exactly once viareadJsonBodyWithLimit, mapped body-read failures to explicit HTTP statuses, and added regression tests for delayed reads, multi-request behavior, near-limit payloads, and >1MB rejection. The webhook is deregistered during restarts, then re-registered when the gateway comes back up.AI Assisted: Used Codex. Took many, many, many iterations to zero in on the minimal change. Lots of manual testing to confirm that the real issue was fixed instead of just causing tests to pass. This took many hours of work even utilizing Codex.
Note - Avoiding Bug in
grammygrammyhas a bug in thehttphandler that results in an uncatchable exception and unresolved promise when the webhook contents are discarded by theguardcallingendbefore thegrammyreader has read any of the data. It's not possible to continue to use thehttphandler until that bug is fixed, but it really shouldn't be used even then as consolidating the length check and having only one stream reader is much simpler. The bug fix PR is here:grammyjs/grammY#872
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
400,408,413) instead of surfacing as generic handler failures.getMe) fails, instead of deferring initialization side effects to first incoming webhook request.Security Impact (required)
No)No)Yes)No)No)Yes, explain risk + mitigation:bot.init()/getMeis now executed explicitly during webhook startup. Risk: startup can fail earlier when Telegram API/token is invalid or unreachable. Mitigation: explicit error logging, startup rejection is immediate and observable, and behavior is covered by tests.Repro + Verification
Environment
secret, webhookpath, default body limits/timeoutsSteps
pnpm test src/telegram/webhook.test.tson a baseline with the body-read race behavior (revert the commits up to the lasttestbefore the fixpnpm test src/telegram/webhook.test.ts.Expected
Actual
Evidence
Attach at least one:
Video
See #26156 for video of the issue before the fix. Will attach a video of the fix in action shortly.
Failing Tests - Gateway Restart WebHook Deregistration
After Fix
Fix Reverted
Failing Tests - Stream Reading
After Fix
Fix Reverted
Failing Logs with Fix Reverted
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm test src/telegram/webhook.test.tsCompatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/telegram/webhook.tssrc/telegram/webhook.test.ts(if test expectations need to be reverted together)500responses on valid payloadsRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.