fix(proxy): cap connect tunnel timeouts · openclaw/openclaw@bafa6de
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { EventEmitter } from "node:events"; |
2 | 2 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { MAX_TIMER_TIMEOUT_MS } from "../../shared/number-coercion.js"; |
3 | 4 | |
4 | 5 | class FakeSocket extends EventEmitter { |
5 | 6 | public readonly writes: string[] = []; |
@@ -349,4 +350,27 @@ describe("openHttpConnectTunnel", () => {
|
349 | 350 | await rejected; |
350 | 351 | expect(proxySocket.destroyed).toBe(true); |
351 | 352 | }); |
| 353 | + |
| 354 | +it("caps oversized CONNECT timeouts before arming the watchdog", async () => { |
| 355 | +vi.useFakeTimers(); |
| 356 | +const proxySocket = new FakeSocket(); |
| 357 | +setNextNetSocket(proxySocket); |
| 358 | +const { openHttpConnectTunnel } = await import("./http-connect-tunnel.js"); |
| 359 | + |
| 360 | +const tunnel = openHttpConnectTunnel({ |
| 361 | +proxyUrl: new URL("http://proxy.example:8080"), |
| 362 | +targetHost: "api.push.apple.com", |
| 363 | +targetPort: 443, |
| 364 | +timeoutMs: Number.MAX_SAFE_INTEGER, |
| 365 | +}); |
| 366 | + |
| 367 | +await vi.advanceTimersByTimeAsync(1); |
| 368 | +expect(proxySocket.destroyed).toBe(false); |
| 369 | + |
| 370 | +await vi.advanceTimersByTimeAsync(MAX_TIMER_TIMEOUT_MS - 1); |
| 371 | +await expect(tunnel).rejects.toThrow( |
| 372 | +`Proxy CONNECT failed via http://proxy.example:8080: Proxy CONNECT timed out after ${MAX_TIMER_TIMEOUT_MS}ms`, |
| 373 | +); |
| 374 | +expect(proxySocket.destroyed).toBe(true); |
| 375 | +}); |
352 | 376 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。