Skip to content

Commit

Permalink
!fixup: [wrangler] fix: stop rebuild attempts when sources are missing (
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusdahlstrand committed Jan 31, 2024
1 parent c0d2ce2 commit b339e06
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
39 changes: 39 additions & 0 deletions fixtures/pages-workerjs-app/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions fixtures/pages-workerjs-app/workerjs-test/_routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 1,
"description": "",
"include": [
"/*"
],
"exclude": []
}

0 comments on commit b339e06

Please sign in to comment.