Skip to content

Commit 07ead90

Browse files
committed
refactor(core): remove startup prewarm of Telegram SDK
- Eliminates unconditional outbound call to telegram.org on every start - Fixes `go test ./internal/server` hitting real network during Manager construction - Leaves background stale-refresh path intact in `refreshTelegramSDK`
1 parent e8bb6ce commit 07ead90

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

internal/core/manager.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,12 @@ func New(st *store.Store, sup *xray.Supervisor, opts xray.Options, tls TLSPaths,
289289
m.startWebhookWorkers() // drain the outbound-webhook delivery queue
290290
go m.prewarmRoutingTemplates() // warm the routing-template cache so the first
291291
// Happ/INCY sub pull after a restart doesn't block
292-
go m.refreshTelegramSDK() // warm telegram-web-app.js so the first subscription-page
293-
// view doesn't pay for the fetch inline
292+
// NOTE: telegram-web-app.js is deliberately NOT prewarmed here. The cold path in
293+
// TelegramWebAppSDK fetches it inline and serves it, so a warm-up would only save
294+
// the first subscription-page view ~120ms — not worth an unconditional outbound
295+
// call to telegram.org on every single start (a beacon the decoy story doesn't
296+
// cover, and one that made `go test ./internal/server` hit the real network,
297+
// since its tests build a Manager through New).
294298
// NOTE: the initial proxy-pool load is done synchronously by main.go via
295299
// SeedProxies() before the first reconcile, so Xray starts once (with proxies)
296300
// rather than starting empty and restarting when a background fetch lands.

internal/core/manager_settings.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,9 @@ var telegramSDKFetch = func(ctx context.Context) ([]byte, error) {
697697
return netguard.Get(ctx, telegramSDKURL, telegramSDKMaxBytes)
698698
}
699699

700-
// refreshTelegramSDK fetches in the background (startup warm-up and stale refresh).
701-
// It's a no-op while a fetch is in flight OR while the failure cooldown is armed.
700+
// refreshTelegramSDK refreshes a stale copy in the background (the only caller —
701+
// there is no startup warm-up, see New). It's a no-op while a fetch is in flight OR
702+
// while the failure cooldown is armed.
702703
//
703704
// That cooldown is what stops a failing upstream from becoming a retry loop: a
704705
// failed fetch never advances tgSDKAt, so a stale copy stays stale and EVERY

0 commit comments

Comments
 (0)