Commite8a6471cRecorded30 Jun 2026Repositorysigil-telegram
Bump sigil-telegram to 0.10.4
Message
Add an opt-in connect-timeout (seconds) on tg-client + make-tg-bot, threaded through tg-api-call into http-post/json's connect-timeout:, so the bot can bound the TCP connect to api.telegram.org (covering both the getUpdates poll and sends). Relock onto sigil-http 0.16.5. Default #f keeps blocking connect. Distinct from request-timeout (the read).
Changed
package.sgl | 2 +-
sigil.lock | 8 ++++----
src/sigil/telegram/bot.sgl | 18 +++++++++++++-----
src/sigil/telegram/client.sgl | 11 +++++++++--
4 files changed, 27 insertions(+), 12 deletions(-)Diff
package.sglmodified
@@ -6,7 +6,7 @@
6
7
(package 8
name: "sigil-telegram"−9
version: "0.10.3"+9
version: "0.10.4" 10
sigil: "^0.17" 11
description: "Telegram Bot API client library" 12
url: "https://codeberg.org/sigil/sigil-telegram"sigil.lockmodified
@@ -14,8 +14,8 @@
14
(package name: "sigil-http" 15
url: "codeberg:sigil/sigil-http" 16
ref: "^0.16.0"−17
sha: "6fe35c36fee7a196cb198e2562b2913ab6a8c51b"−18
version: "0.16.4")+17
sha: "ea578f14613951d5da5446da04bdb5d2d1ee9cbf"+18
version: "0.16.5") 19
(package name: "sigil-test" 20
url: "codeberg:sigil/sigil" 21
ref: "^0.17"@@ -36,8 +36,8 @@
36
(package name: "sigil-tls" 37
url: "codeberg:sigil/sigil-tls" 38
ref: "^0.16.0"−39
sha: "407d9d63ccb6a75a88f39f0588bf012c0eed2d6e"−40
version: "0.16.1")+39
sha: "e67c3b00b19bc495e38527203d0a563a8bcd5eab"+40
version: "0.16.2") 41
(package name: "sigil-ansi" 42
url: "codeberg:sigil/sigil-ansi" 43
ref: "^0.16.0"src/sigil/telegram/bot.sglmodified
@@ -64,24 +64,32 @@
64
;;; The optional `request-timeout:` (seconds) bounds the HTTP read 65
;;; on every API call the bot makes — both the getUpdates poll and 66
;;; outbound sends — so a half-open connection raises instead of−67
;;; hanging. Omitted/#f keeps the original blocking behavior.+67
;;; hanging. The optional `connect-timeout:` (seconds) bounds the+68
;;; TCP connect, so a blackholed api.telegram.org CDN IP can't hang+69
;;; on the OS SYN timeout. Both default #f (original blocking+70
;;; behavior). 71
;;; 72
;;; ```scheme 73
;;; (define bot (make-tg-bot 74
;;; token: "123456:ABC-DEF..." 75
;;; allowed-chats: '(12345 67890)−73
;;; request-timeout: 25))+76
;;; request-timeout: 25+77
;;; connect-timeout: 10)) 78
;;; ``` 79
(define (make-tg-bot (keys: (token #f) 80
(allowed-chats #f) 81
(allowed-users #f)−78
(request-timeout #f)))+82
(request-timeout #f)+83
(connect-timeout #f))) 84
(: (token: string?) (allowed-chats: (maybe list?)) 85
(allowed-users: (maybe list?))−81
(request-timeout: (maybe number?)) -> tg-bot?)+86
(request-timeout: (maybe number?))+87
(connect-timeout: (maybe number?)) -> tg-bot?) 88
(unless token (error "make-tg-bot: token: is required")) 89
(tg-bot−84
client: (tg-client token: token request-timeout: request-timeout)+90
client: (tg-client token: token+91
request-timeout: request-timeout+92
connect-timeout: connect-timeout) 93
allowed-chats: allowed-chats 94
allowed-users: allowed-users)) 95
src/sigil/telegram/client.sglmodified
@@ -22,6 +22,7 @@
22
tg-client tg-client? tg-client-token 23
tg-client-last-update-id set-tg-client-last-update-id! 24
tg-client-request-timeout+25
tg-client-connect-timeout 26
27
;; Core API 28
tg-api-call@@ -74,7 +75,12 @@
75
;; When set, every tg-api-call bounds its response read so a 76
;; half-open connection raises instead of hanging. Distinct from 77
;; the getUpdates long-poll `timeout:` (Telegram-side wait).−77
(request-timeout default: #f))+78
(request-timeout default: #f)+79
;; Optional connect timeout in seconds (#f = blocking connect, the+80
;; default). When set, bounds the TCP connect to api.telegram.org so+81
;; a blackholed CDN IP can't hang on the OS SYN timeout (~127s) past+82
;; the poller's watchdog. Distinct from request-timeout (the read).+83
(connect-timeout default: #f)) 84
85
;; ============================================================ 86
;; Core API Call@@ -99,7 +105,8 @@
105
(define (tg-api-call client method (keys: (params #{}))) 106
(: tg-client? string? (params: dict?) -> any?) 107
(let ((response (http-post/json (api-url client method) params−102
timeout: (tg-client-request-timeout client))))+108
timeout: (tg-client-request-timeout client)+109
connect-timeout: (tg-client-connect-timeout client)))) 110
(unless response 111
(error (string-append "tg-api-call: HTTP request failed for " method))) 112
(if (eq? (dict-ref response ok: #f) #t)