From 3407de5cbeb9195b6395497325779476196aa350 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 00:37:39 +0000 Subject: [PATCH] [Tests] Cover the Cloudflare tunnel timeout with no reported error The tunnel timeout handler has two branches: it reports the last collected cloudflared errors, or falls back to "unknown error." when none were collected. Only the first branch was exercised, so the fallback message could change or break without any test noticing. Add a case that writes a log line matching neither the URL, connection, nor known-error patterns, then advances the fake clock past the unit-test tunnel timeout. Co-Authored-By: Claude Opus 4.8 --- packages/plugin-cloudflare/src/tunnel.test.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/plugin-cloudflare/src/tunnel.test.ts b/packages/plugin-cloudflare/src/tunnel.test.ts index 57baee395e4..16ed587de5d 100644 --- a/packages/plugin-cloudflare/src/tunnel.test.ts +++ b/packages/plugin-cloudflare/src/tunnel.test.ts @@ -146,6 +146,31 @@ describe('hookStart', () => { } }) + test('reports an unknown error when the tunnel times out without printing a URL or a known error', async () => { + // Given + vi.useFakeTimers() + try { + vi.mocked(exec).mockImplementationOnce(async (command, args, options) => { + const writable = options?.stdout as Writable + writable.write(Buffer.from(`2023-01-30T15:37:11Z INF Starting tunnel`)) + }) + + // When + const tunnelClient = (await hookStart(port)).valueOrAbort() + await vi.advanceTimersByTimeAsync(250) + const result = tunnelClient.getTunnelStatus() + + // Then + expect(result).toEqual({ + status: 'error', + message: 'Could not start Cloudflare tunnel: unknown error.', + tryMessage: expect.anything(), + }) + } finally { + vi.useRealTimers() + } + }) + test('returns error if it fails to install cloudflared', async () => { // Given vi.mocked(install).mockReturnValueOnce(Promise.reject(new Error('Failed to install cloudflared')))