MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / withTimeout

Function withTimeout

quote/quote.ts:220–228  ·  view source on GitHub ↗

* Race a promise against a timeout. On timeout the returned promise REJECTS with * QuoteTimeoutError (so the caller's try/catch can report it) and the timer is * always cleared to avoid leaks. The underlying RPC is abandoned, not cancelled — * gramjs has no cancel — but it no longer blocks the co

(promise: Promise<T>, ms: number, label: string)

Source from the content-addressed store, hash-verified

218class QuoteTimeoutError extends Error {
219 constructor(label: string, ms: number) {
220 super(`quote operation "${label}" timed out after ${ms}ms (likely a stalled Telegram RPC during a connection drop)`);
221 this.name = "QuoteTimeoutError";
222 }
223}
224
225/**
226 * Race a promise against a timeout. On timeout the returned promise REJECTS with
227 * QuoteTimeoutError (so the caller's try/catch can report it) and the timer is
228 * always cleared to avoid leaks. The underlying RPC is abandoned, not cancelled —
229 * gramjs has no cancel — but it no longer blocks the command from completing.
230 */
231function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {

Callers 4

collectMessagesFunction · 0.85
editProgressFunction · 0.85
handleQuoteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected