Skip to content

Commit 60e96a3

Browse files
committed
fix(auth): clamp negative timeouts
1 parent 7407545 commit 60e96a3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kfastov/tgcli",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"type": "module",
55
"description": "Telegram CLI + MCP server powered by MTProto and the official MCP SDK",
66
"main": "mcp-server.js",

telegram-client.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ import path from 'path';
66
import fs from 'fs';
77
import { resolveStoreDir, resolveStorePaths } from './core/store.js';
88

9+
const timeoutPatchKey = Symbol.for('tgcli.timeoutPatch');
10+
if (!globalThis[timeoutPatchKey]) {
11+
const originalSetTimeout = globalThis.setTimeout;
12+
if (typeof originalSetTimeout === 'function') {
13+
const wrapped = (handler, delay, ...args) => {
14+
const safeDelay = Number.isFinite(delay) ? Math.max(0, delay) : 0;
15+
return originalSetTimeout(handler, safeDelay, ...args);
16+
};
17+
globalThis.setTimeout = wrapped;
18+
}
19+
globalThis[timeoutPatchKey] = true;
20+
}
21+
922
const DEFAULT_STORE_DIR = resolveStoreDir();
1023
const { sessionPath: DEFAULT_SESSION_PATH } = resolveStorePaths(DEFAULT_STORE_DIR);
1124
const DEFAULT_DOWNLOAD_DIR = path.join(DEFAULT_STORE_DIR, 'downloads');

0 commit comments

Comments
 (0)