fix: honor Telegram proxy dispatcher (#4456) (thanks @spiceoogway)

This commit is contained in:
Ayaan Zaidi
2026-01-30 14:37:17 +05:30
parent 7150268f84
commit 3a85cb1833
2 changed files with 46 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ Status: stable.
- **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed).
### Fixes
- Telegram: use undici fetch for per-account proxy dispatcher. (#4456) Thanks @spiceoogway.
- Telegram: avoid silent empty replies by tracking normalization skips before fallback. (#3796)
- Telegram: scope native skill commands to bound agent per bot. (#4360) Thanks @robhparker.
- Mentions: honor mentionPatterns even when explicit mentions are present. (#3303) Thanks @HirokiKobayashi-R.

View File

@@ -0,0 +1,45 @@
import { describe, expect, it, vi } from "vitest";
const { ProxyAgent, undiciFetch, proxyAgentSpy, getLastAgent } = vi.hoisted(() => {
const undiciFetch = vi.fn();
const proxyAgentSpy = vi.fn();
class ProxyAgent {
static lastCreated: ProxyAgent | undefined;
proxyUrl: string;
constructor(proxyUrl: string) {
this.proxyUrl = proxyUrl;
ProxyAgent.lastCreated = this;
proxyAgentSpy(proxyUrl);
}
}
return {
ProxyAgent,
undiciFetch,
proxyAgentSpy,
getLastAgent: () => ProxyAgent.lastCreated,
};
});
vi.mock("undici", () => ({
ProxyAgent,
fetch: undiciFetch,
}));
import { makeProxyFetch } from "./proxy.js";
describe("makeProxyFetch", () => {
it("uses undici fetch with ProxyAgent dispatcher", async () => {
const proxyUrl = "http://proxy.test:8080";
undiciFetch.mockResolvedValue({ ok: true });
const proxyFetch = makeProxyFetch(proxyUrl);
await proxyFetch("https://api.telegram.org/bot123/getMe");
expect(proxyAgentSpy).toHaveBeenCalledWith(proxyUrl);
expect(undiciFetch).toHaveBeenCalledWith(
"https://api.telegram.org/bot123/getMe",
expect.objectContaining({ dispatcher: getLastAgent() }),
);
});
});