Skip to content

Commit ad02ad3

Browse files
add warning for when users run wrangler dev --remote with (enabled) containers (#9976)
* add warning for when users run `wrangler dev --remote` with (enabled) containers * remove incorrect @inheritable tag from dev.enable_containers config
1 parent 44ed0cb commit ad02ad3

File tree

4 files changed

+88
-10
lines changed

4 files changed

+88
-10
lines changed

.changeset/tidy-plants-dance.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+
add warning for when users run `wrangler dev --remote` with (enabled) containers

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ vi.mock("../api/startDevWorker/ConfigController", (importOriginal) =>
3737

3838
vi.mock("../dev/hotkeys");
3939

40+
vi.mock("@cloudflare/containers-shared", async (importOriginal) => {
41+
return {
42+
...(await importOriginal()),
43+
isDockerfile: () => true,
44+
};
45+
});
46+
4047
// Don't memoize in tests. If we did, it would memoize across test runs, which causes problems
4148
vi.mock("../utils/memoizeGetPort", () => {
4249
return {
@@ -1782,6 +1789,59 @@ describe.sequential("wrangler dev", () => {
17821789
expect(std.warn).toMatchInlineSnapshot(`""`);
17831790
});
17841791
});
1792+
1793+
describe("containers", () => {
1794+
it("should warn when run in remote mode with (enabled) containers", async () => {
1795+
writeWranglerConfig({
1796+
main: "index.js",
1797+
compatibility_date: "2024-01-01",
1798+
containers: [
1799+
{
1800+
class_name: "ContainerClass",
1801+
image: "./Dockerfile",
1802+
},
1803+
],
1804+
});
1805+
fs.writeFileSync("index.js", `export default {};`);
1806+
1807+
await expect(
1808+
runWrangler("dev --remote")
1809+
).rejects.toThrowErrorMatchingInlineSnapshot(
1810+
"[Error: Bailing early in tests]"
1811+
);
1812+
1813+
expect(std.warn).toMatchInlineSnapshot(`
1814+
"▲ [WARNING] Containers are only supported in local mode, to suppress this warning set \`dev.enable_containers\` to \`false\` or pass \`--enable-containers=false\` to the \`wrangler dev\` command
1815+
1816+
"
1817+
`);
1818+
});
1819+
1820+
it("should not warn when run in remote mode with disabled containers", async () => {
1821+
writeWranglerConfig({
1822+
main: "index.js",
1823+
compatibility_date: "2024-01-01",
1824+
containers: [
1825+
{
1826+
class_name: "ContainerClass",
1827+
image: "./Dockerfile",
1828+
},
1829+
],
1830+
dev: {
1831+
enable_containers: false,
1832+
},
1833+
});
1834+
fs.writeFileSync("index.js", `export default {};`);
1835+
1836+
await expect(
1837+
runWrangler("dev --remote")
1838+
).rejects.toThrowErrorMatchingInlineSnapshot(
1839+
"[Error: Bailing early in tests]"
1840+
);
1841+
1842+
expect(std.warn).toMatchInlineSnapshot(`""`);
1843+
});
1844+
});
17851845
});
17861846

17871847
function mockGetZones(domain: string, zones: { id: string }[] = []) {

packages/wrangler/src/api/startDevWorker/ConfigController.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,29 @@ async function resolveConfig(
416416
logger.warn("Queues are not yet supported in wrangler dev remote mode.");
417417
}
418418

419-
// TODO(do) support remote wrangler dev
420-
const classNamesWhichUseSQLite = getClassNamesWhichUseSQLite(
421-
resolved.migrations
422-
);
423-
if (
424-
resolved.dev.remote &&
425-
Array.from(classNamesWhichUseSQLite.values()).some((v) => v)
426-
) {
427-
logger.warn("SQLite in Durable Objects is only supported in local mode.");
419+
if (resolved.dev.remote) {
420+
// We're in remote mode (`--remote`)
421+
422+
if (
423+
resolved.dev.enableContainers &&
424+
resolved.containers &&
425+
resolved.containers.length > 0
426+
) {
427+
logger.warn(
428+
"Containers are only supported in local mode, to suppress this warning set `dev.enable_containers` to `false` or pass `--enable-containers=false` to the `wrangler dev` command"
429+
);
430+
}
431+
432+
// TODO(do) support remote wrangler dev
433+
const classNamesWhichUseSQLite = getClassNamesWhichUseSQLite(
434+
resolved.migrations
435+
);
436+
if (
437+
resolved.dev.remote &&
438+
Array.from(classNamesWhichUseSQLite.values()).some((v) => v)
439+
) {
440+
logger.warn("SQLite in Durable Objects is only supported in local mode.");
441+
}
428442
}
429443

430444
// prompt user to update their types if we detect that it is out of date

packages/wrangler/src/config/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ export interface DevConfig {
238238
* When developing, whether to build and connect to containers. This requires a Docker daemon to be running.
239239
* Defaults to `true`.
240240
*
241-
* @inheritable
242241
* @default true
243242
*/
244243
enable_containers: boolean;

0 commit comments

Comments
 (0)