Skip to content

Commit ffa742f

Browse files
fix: ensure that wrangler deploy and version upload don't override the remote-bindings flag (#9673)
* fix: ensure that wrangler deploy and version upload don't override the remote-bindings flag * add tests for wrangler deploy and version upload
1 parent 9d778ce commit ffa742f

File tree

5 files changed

+93
-2
lines changed

5 files changed

+93
-2
lines changed

.changeset/better-rings-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: ensure that wrangler deploy and version upload don't override the remote-bindings flag

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13068,6 +13068,42 @@ export default{
1306813068
});
1306913069
});
1307013070

13071+
it("should warn about unexpected experimental_remote fields", async () => {
13072+
writeWorkerSource();
13073+
writeWranglerConfig({
13074+
main: "./index.js",
13075+
kv_namespaces: [
13076+
{ binding: "MY_KV", id: "kv-id-xxx", experimental_remote: true },
13077+
],
13078+
});
13079+
mockSubDomainRequest();
13080+
mockUploadWorkerRequest();
13081+
13082+
await runWrangler("deploy");
13083+
13084+
expect(std.warn).toContain(
13085+
'Unexpected fields found in kv_namespaces[0] field: "experimental_remote"'
13086+
);
13087+
});
13088+
13089+
it("should not warn about experimental_remote fields when --x-remote-bindings is provided", async () => {
13090+
writeWorkerSource();
13091+
writeWranglerConfig({
13092+
main: "./index.js",
13093+
kv_namespaces: [
13094+
{ binding: "MY_KV", id: "kv-id-xxx", experimental_remote: true },
13095+
],
13096+
});
13097+
mockSubDomainRequest();
13098+
mockUploadWorkerRequest();
13099+
13100+
await runWrangler("deploy --x-remote-bindings");
13101+
13102+
expect(std.warn).not.toContain(
13103+
'Unexpected fields found in kv_namespaces[0] field: "experimental_remote"'
13104+
);
13105+
});
13106+
1307113107
describe("multi-env warning", () => {
1307213108
it("should warn if the wrangler config contains environments but none was specified in the command", async () => {
1307313109
writeWorkerSource();

packages/wrangler/src/__tests__/versions/versions.upload.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,56 @@ describe("versions upload", () => {
211211
expect(std.info).toContain("Retrying API call after error...");
212212
});
213213

214+
it("should warn about unexpected experimental_remote fields", async () => {
215+
mockGetScript();
216+
mockUploadVersion(true);
217+
mockGetWorkerSubdomain({ enabled: true, previews_enabled: false });
218+
219+
// Setup
220+
writeWranglerConfig({
221+
name: "test-name",
222+
main: "./index.js",
223+
kv_namespaces: [
224+
{ binding: "MY_KV", id: "kv-id-xxx", experimental_remote: true },
225+
],
226+
});
227+
writeWorkerSource();
228+
setIsTTY(false);
229+
230+
const result = runWrangler("versions upload");
231+
232+
await expect(result).resolves.toBeUndefined();
233+
234+
expect(std.warn).toContain(
235+
'Unexpected fields found in kv_namespaces[0] field: "experimental_remote"'
236+
);
237+
});
238+
239+
it("should not warn about experimental_remote fields when --x-remote-bindings is provided", async () => {
240+
mockGetScript();
241+
mockUploadVersion(true);
242+
mockGetWorkerSubdomain({ enabled: true, previews_enabled: false });
243+
244+
// Setup
245+
writeWranglerConfig({
246+
name: "test-name",
247+
main: "./index.js",
248+
kv_namespaces: [
249+
{ binding: "MY_KV", id: "kv-id-xxx", experimental_remote: true },
250+
],
251+
});
252+
writeWorkerSource();
253+
setIsTTY(false);
254+
255+
const result = runWrangler("versions upload --x-remote-bindings");
256+
257+
await expect(result).resolves.toBeUndefined();
258+
259+
expect(std.warn).not.toContain(
260+
'Unexpected fields found in kv_namespaces[0] field: "experimental_remote"'
261+
);
262+
});
263+
214264
describe("multi-env warning", () => {
215265
it("should warn if the wrangler config contains environments but none was specified in the command", async () => {
216266
mockGetScript();

packages/wrangler/src/deploy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export const deployCommand = createCommand({
220220
overrideExperimentalFlags: (args) => ({
221221
MULTIWORKER: false,
222222
RESOURCES_PROVISION: args.experimentalProvision ?? false,
223-
REMOTE_BINDINGS: false,
223+
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false,
224224
}),
225225
warnIfMultipleEnvsConfiguredButNoneSpecified: true,
226226
},

packages/wrangler/src/versions/upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export const versionsUploadCommand = createCommand({
264264
overrideExperimentalFlags: (args) => ({
265265
MULTIWORKER: false,
266266
RESOURCES_PROVISION: args.experimentalProvision ?? false,
267-
REMOTE_BINDINGS: false,
267+
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false,
268268
}),
269269
warnIfMultipleEnvsConfiguredButNoneSpecified: true,
270270
},

0 commit comments

Comments
 (0)