From 2cbf69c37e366f1ac06d1d8db5351f2ddc9332a1 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 19 Oct 2026 10:41:45 +0200 Subject: [PATCH] test(cloudflare): Request workers over IPv4 in integration tests wrangler only binds the worker port on 127.0.0.1, so requesting `localhost` (which resolves to ::1 first) could connect to another wrangler's inspector that happened to get the same port number on ::1, failing with a 500 "Not yet implemented". Co-Authored-By: Claude Opus 5.5 --- dev-packages/cloudflare-integration-tests/runner.ts | 4 +++- .../suites/public-api/startSpan/test.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dev-packages/cloudflare-integration-tests/runner.ts b/dev-packages/cloudflare-integration-tests/runner.ts index 69ab9e20fc2e..a389543df706 100644 --- a/dev-packages/cloudflare-integration-tests/runner.ts +++ b/dev-packages/cloudflare-integration-tests/runner.ts @@ -557,7 +557,9 @@ export function createRunner(...paths: string[]) { path: string, options: { headers?: Record; data?: BodyInit; expectError?: boolean } = {}, ): Promise { - const url = `http://localhost:${await workerPortPromise}${path}`; + // wrangler only binds this port on 127.0.0.1. `localhost` resolves to ::1 first, where the same + // port number can belong to another wrangler's inspector, which answers 500 "Not yet implemented". + const url = `http://127.0.0.1:${await workerPortPromise}${path}`; const body = options.data; const headers = options.headers || {}; const expectError = options.expectError || false; diff --git a/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts b/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts index 0fa5d410368b..b75437a4ff0d 100644 --- a/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/public-api/startSpan/test.ts @@ -203,11 +203,11 @@ it('sends a streamed span envelope with correct spans for a manually started spa [SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' }, 'server.address': { type: 'string', - value: 'localhost', + value: '127.0.0.1', }, 'url.full': { type: 'string', - value: expect.stringMatching(/^http:\/\/localhost:.+$/), + value: expect.stringMatching(/^http:\/\/127\.0\.0\.1:.+$/), }, 'url.path': { type: 'string', @@ -247,7 +247,7 @@ it('sends a streamed span envelope with correct spans for a manually started spa }, 'http.request.header.host': { type: 'array', - value: [expect.stringMatching(/^localhost:.+$/)], + value: [expect.stringMatching(/^127\.0\.0\.1:.+$/)], }, 'http.request.header.sec-fetch-mode': { type: 'array',