Skip to content

Commit 36113c2

Browse files
penalosaclaude
andauthored
fix: use connect_pass_through flag instead of workaround for TCP regression (#9506)
* Revert "fix: strips CF-Connecting-IP header within Wrangler (#9246)" This reverts commit d033a7d. * feat: add connect_pass_through compatibility flag to globalOutbound worker Add the connect_pass_through compatibility flag to the outbound service worker that strips CF-Connecting-IP headers. This resolves the TCP connection regression that was introduced when using globalOutbound service with workerd's connect() API. The connect_pass_through flag was added in workerd PR #4171 to fix the underlying issue, allowing us to remove the JavaScript injection workaround and use the cleaner global outbound approach. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: add connect_pass_through and experimental compat flags, add changeset - Add 'experimental' compat flag alongside 'connect_pass_through' - Add changeset for the TCP regression fix - The deleted test was specific to the workaround we're replacing * human fixups * fix lockfile * fix lockfile * fix lockfile --------- Co-authored-by: Claude <[email protected]>
1 parent 4e16a75 commit 36113c2

File tree

8 files changed

+14
-180
lines changed

8 files changed

+14
-180
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"miniflare": patch
3+
"wrangler": patch
4+
---
5+
6+
Strip the `CF-Connecting-IP` header from outgoing fetches

packages/miniflare/src/plugins/core/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ const CoreOptionsSchemaInput = z.intersection(
165165
tails: z.array(ServiceDesignatorSchema).optional(),
166166

167167
// Strip the CF-Connecting-IP header from outbound fetches
168-
// There is an issue with the connect() API and the globalOutbound workerd setting that impacts TCP ingress
169-
// We should default it to true once https://github.com/cloudflare/workerd/pull/4145 is resolved
170-
stripCfConnectingIp: z.boolean().default(false),
168+
stripCfConnectingIp: z.boolean().default(true),
171169
})
172170
);
173171
export const CoreOptionsSchema = CoreOptionsSchemaInput.transform((value) => {
@@ -839,6 +837,7 @@ export const CORE_PLUGIN: Plugin<
839837
},
840838
],
841839
compatibilityDate: "2025-01-01",
840+
compatibilityFlags: ["connect_pass_through", "experimental"],
842841
globalOutbound: getGlobalOutbound(workerIndex, options),
843842
},
844843
});

packages/miniflare/test/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3035,7 +3035,6 @@ test("Miniflare: strips CF-Connecting-IP", async (t) => {
30353035
const client = new Miniflare({
30363036
script: `export default { fetch(request) { return fetch('${serverUrl.href}', {headers: {"CF-Connecting-IP":"fake-value"}}) } }`,
30373037
modules: true,
3038-
stripCfConnectingIp: true,
30393038
});
30403039
t.teardown(() => client.dispose());
30413040
t.teardown(() => server.dispose());

packages/unenv-preset/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"peerDependencies": {
5656
"unenv": "2.0.0-rc.17",
57-
"workerd": "^1.20250508.0"
57+
"workerd": "^1.20250521.0"
5858
},
5959
"peerDependenciesMeta": {
6060
"workerd": {

packages/wrangler/src/__tests__/api/startDevWorker/startWorker.test.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/wrangler/src/deployment-bundle/bundle.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -261,32 +261,6 @@ export async function bundleWorker(
261261
inject.push(checkedFetchFileToInject);
262262
}
263263

264-
// We injected the `CF-Connecting-IP` header in the entry worker on Miniflare.
265-
// It used to be stripped by Miniflare, but that caused TCP ingress failures
266-
// because of the global outbound setup. This is a temporary workaround until
267-
// a proper fix is landed in Workerd.
268-
// See https://github.com/cloudflare/workers-sdk/issues/9238 for more details.
269-
if (targetConsumer === "dev" && local) {
270-
const stripCfConnectingIpHeaderFileToInject = path.join(
271-
tmpDir.path,
272-
"strip-cf-connecting-ip-header.js"
273-
);
274-
275-
if (!fs.existsSync(stripCfConnectingIpHeaderFileToInject)) {
276-
fs.writeFileSync(
277-
stripCfConnectingIpHeaderFileToInject,
278-
fs.readFileSync(
279-
path.resolve(
280-
getBasePath(),
281-
"templates/strip-cf-connecting-ip-header.js"
282-
)
283-
)
284-
);
285-
}
286-
287-
inject.push(stripCfConnectingIpHeaderFileToInject);
288-
}
289-
290264
// When multiple workers are running we need some way to disambiguate logs between them. Inject a patched version of `globalThis.console` that prefixes logs with the worker name
291265
if (getFlag("MULTIWORKER")) {
292266
middlewareToLoad.push({

packages/wrangler/templates/strip-cf-connecting-ip-header.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)