From b339e062afd699f6470226cafdb0556843dae2cf Mon Sep 17 00:00:00 2001 From: Magnus Dahlstrand Date: Wed, 31 Jan 2024 17:15:17 +0000 Subject: [PATCH] !fixup: [wrangler] fix: stop rebuild attempts when sources are missing (#3886) --- .../pages-workerjs-app/tests/index.test.ts | 39 +++++++++++++++++++ .../workerjs-test/_routes.json | 8 ++++ 2 files changed, 47 insertions(+) create mode 100644 fixtures/pages-workerjs-app/workerjs-test/_routes.json diff --git a/fixtures/pages-workerjs-app/tests/index.test.ts b/fixtures/pages-workerjs-app/tests/index.test.ts index f68baee29f38..34398e2b43be 100644 --- a/fixtures/pages-workerjs-app/tests/index.test.ts +++ b/fixtures/pages-workerjs-app/tests/index.test.ts @@ -100,6 +100,45 @@ describe("Pages _worker.js", () => { } }); + it("should not error if the _routes.json file is removed while watching", async ({ + expect, + }) => { + const basePath = resolve(__dirname, ".."); + const { ip, port, getOutput, clearOutput, stop } = + await runWranglerPagesDev(resolve(__dirname, ".."), "./workerjs-test", [ + "--port=0", + "--inspector-port=0", + ]); + try { + clearOutput(); + await tryRename( + basePath, + "workerjs-test/_routes.json", + "workerjs-test/XXX_routes.json" + ); + await setTimeout(1000); + // Expect no output since the deletion of the routes file should be ignored + expect(getOutput()).toBe(""); + await tryRename( + basePath, + "workerjs-test/XXX_routes.json", + "workerjs-test/_routes.json" + ); + await setTimeout(1000); + // Expect replacing the routes file to trigger a build, although + // the routes build does not provide any output feedback to compare against, + // so we just check that nothing else is being printed. + expect(getOutput()).toBe(""); + } finally { + await stop(); + await tryRename( + basePath, + "workerjs-test/XXX_routes.json", + "workerjs-test/_routes.json" + ); + } + }); + async function tryRename( basePath: string, from: string, diff --git a/fixtures/pages-workerjs-app/workerjs-test/_routes.json b/fixtures/pages-workerjs-app/workerjs-test/_routes.json new file mode 100644 index 000000000000..ecf7343859e6 --- /dev/null +++ b/fixtures/pages-workerjs-app/workerjs-test/_routes.json @@ -0,0 +1,8 @@ +{ + "version": 1, + "description": "", + "include": [ + "/*" + ], + "exclude": [] +} \ No newline at end of file