Repository navigation
fix(telegram): catch unhandled rejections in webhook and ingress worker shutdown - #100998
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 29, 2026, 1:16 PM ET / 17:16 UTC. ClawSweeper reviewWhat this changesThis PR changes Telegram webhook shutdown so failures in one teardown phase are logged and do not prevent later bot, transport, ingress, status, or diagnostics cleanup. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain The shutdown approach is plausible and the supplied diff is focused, but this review cannot reach a merge-ready verdict because the required read-only sandbox failed before it could inspect the full on-disk policy, final-head source context, history, maintainer notes, or the claimed runtime proof. Likely related people: vincentkoc (recent current-head contributor, medium confidence) and Pick-cat (earlier implementation contributor, medium confidence). Priority: P2 Review scores
Verification
How this fits togetherTelegram webhook mode owns a local server, bot, transport, ingress monitor, status publishing, and optional diagnostics. Abort signals and explicit stop calls enter the webhook shutdown path, which should release each resource and leave the channel visibly disconnected. flowchart LR
A[Abort signal or stop call] --> B[Telegram webhook shutdown]
B --> C[Isolate teardown phases]
C --> D[Server and bot cleanup]
C --> E[Transport and ingress cleanup]
C --> F[Status and diagnostics cleanup]
D --> G[Clean channel shutdown]
E --> G
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +17, Tests +22. Total +39 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one non-rejecting webhook shutdown owner, verify every shutdown caller against the final head, and attach inspectable redacted after-fix terminal output or logs that show an injected teardown rejection is logged while subsequent transport and status cleanup complete. Do we have a high-confidence way to reproduce the issue? No high-confidence runtime reproduction is available to this review. The supplied diff and PR body describe a clear failure-injection path, but the final-head harness and its observed output could not be inspected after repository access failed. Is this the best way to solve the issue? Unclear. Per-phase error isolation is a maintainable shape for a non-rejecting shutdown path, but the required caller, sibling-path, and final-head proof review could not be completed. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against a47d81e7b33b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (26 earlier review cycles; latest 8 shown)
|
76914e9 to
0bcd6e5
Compare
|
@clawsweeper re-review Patch-quality blockers from the previous review have been addressed and CI is green (check-test-types, check-lint, and Real behavior proof all pass). Please re-evaluate. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Force-pushed an updated head (0bcd6e562e) after addressing the review blockers. Please re-evaluate against the current commit. |
|
@clawsweeper re-review Added a real ClickClack gateway reconnect proof using local HTTP/WebSocket servers driving the production function. The script shows abort resolves a pending 60s reconnect delay in ~50ms, plus a raw-setTimeout negative control for comparison. |
0bcd6e5 to
3e4ead5
Compare
d13b82c to
29b6a1d
Compare
|
@clawsweeper re-review Rebased to latest main (head now 29b6a1d556). PR body includes the real ClickClack gateway reconnect proof with local HTTP/WebSocket servers. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
29b6a1d to
7122e7c
Compare
06d4e7f to
470b751
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. |
dc6452b to
115b318
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
fb257d4 to
aac474a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
…rd all cleanup - Wrap entire shutdown() body in outer try/catch so sync throws never produce unhandled rejections from fire-and-forget abort listeners. - bot.stop() rejection is caught and logged; finally block ensures closeTransportOnce(), noteWebhookStop(), and stopDiagnosticHeartbeat() always execute regardless of bot.stop() outcome. - closeTransportOnce() rejection is caught independently in the finally block so noteWebhookStop() and stopDiagnosticHeartbeat() are not skipped. - Startup failure path: bot.stop() and closeTransportOnce() get .catch(() => undefined) so cleanup rejections never mask the original startup error. - Both abort-listener call sites use consistent void shutdown() since the never-reject contract is now internal. - Ingress worker stop() shares an in-flight stopPromise for idempotency; worker.terminate() rejections are observed via .catch(() => undefined). Co-Authored-By: nebulacoder-v8.0 <[email protected]>
Extract independently guarded shutdown phases so a synchronous server.close() failure still runs bot.stop, transport close, status, and diagnostic heartbeat cleanup. Add sync-throw regression coverage and a loopback real-behavior proof (negative/positive/valid).
Restore curly-safe drain timer clear, stop exporting the unused shutdown phases interface, and narrow the transport close spy for tsgo test types.
telegram-reply-fence.ts was deleted on main (f7786a1) during the core drain refactor. The rebased webhook.ts no longer calls these functions; remove the dangling import so the module resolves. Co-Authored-By: nebulacoder-v8.0 <[email protected]>
aac474a to
b9353f5
Compare
Keep each fallible Telegram-owned teardown phase independent so an early failure cannot skip transport, ingress, status, or diagnostic cleanup. Co-authored-by: Pick-cat <[email protected]>
|
Merged via squash.
|
What Problem This Solves
Telegram webhook shutdown could stop at the first rejected cleanup step. A failure in bot, server, transport, ingress, status, or diagnostics teardown could skip every later Telegram-owned phase and surface as an unhandled rejection.
Fix
Keep shutdown ownership in
startTelegramWebhook()and isolate each fallible teardown phase. Every phase reports its own failure and cleanup continues through the remaining transport, ingress, status, and diagnostics steps.This is a current-main rewrite of the contributor PR. Contributor credit is preserved with a co-author trailer.
Evidence
Verified head:
142987eacaaee445b7dab2bafc9122a484827bf1git diff --check, signature verification, privacy scan, and fresh autoreview passed.No configuration, protocol, or public API surface changes.