Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pages tmp dir location #7441

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-lions-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Make sure Wrangler doesn't create a `.wrangler` tmp dir in the `functions/` folder of a Pages project
7 changes: 7 additions & 0 deletions packages/wrangler/e2e/pages-dev.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { existsSync } from "node:fs";
import path from "node:path";
import { setTimeout } from "node:timers/promises";
import getPort from "get-port";
import dedent from "ts-dedent";
Expand Down Expand Up @@ -482,6 +484,11 @@ describe.each([{ cmd: "wrangler pages dev" }])("Pages $cmd", ({ cmd }) => {

text = await fetchText(url);
expect(text).toBe("Updated Worker!");

// Ensure Wrangler doesn't write tmp files in the functions directory—regression test for https://github.com/cloudflare/workers-sdk/issues/7440
expect(
existsSync(path.join(helper.tmpPath, "functions/.wrangler"))
).toBeFalsy();
});

it("should support modifying dependencies during dev session (Functions)", async () => {
Expand Down
90 changes: 45 additions & 45 deletions packages/wrangler/src/__tests__/pages/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,7 @@ Failed to publish your Function. Got error: Uncaught TypeError: a is not a funct
Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
Content-Type: application/javascript+module

// _worker.js
// public/_worker.js
import wasm from \\"./test-hello.wasm\\";
import html from \\"./test-hello.html\\";
var worker_default = {
Expand Down Expand Up @@ -3474,28 +3474,28 @@ Failed to publish your Function. Got error: Uncaught TypeError: a is not a funct
// `bundledWorker`, the wasm import, etc., and since `workerBundle` is
// small enough, let's go ahead and snapshot test the whole thing
expect(workerBundleWithConstantData).toMatchInlineSnapshot(`
"------formdata-undici-0.test
Content-Disposition: form-data; name=\\"metadata\\"

{\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
------formdata-undici-0.test
Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
Content-Type: application/javascript+module

// _worker.js
var worker_default = {
async fetch(request, env) {
const url = new URL(request.url);
return url.pathname.startsWith(\\"/api/\\") ? new Response(\\"Ok\\") : env.ASSETS.fetch(request);
}
};
export {
worker_default as default
};
//# sourceMappingURL=bundledWorker-0.test.mjs.map
"------formdata-undici-0.test
Content-Disposition: form-data; name=\\"metadata\\"

------formdata-undici-0.test--"
`);
{\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
------formdata-undici-0.test
Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
Content-Type: application/javascript+module

// public/_worker.js
var worker_default = {
async fetch(request, env) {
const url = new URL(request.url);
return url.pathname.startsWith(\\"/api/\\") ? new Response(\\"Ok\\") : env.ASSETS.fetch(request);
}
};
export {
worker_default as default
};
//# sourceMappingURL=bundledWorker-0.test.mjs.map

------formdata-undici-0.test--"
`);

expect(JSON.parse(customRoutesJSON)).toMatchObject({
version: ROUTES_SPEC_VERSION,
Expand Down Expand Up @@ -3843,28 +3843,28 @@ and that at least one include rule is provided.
// `bundledWorker`, the wasm import, etc., and since `workerBundle` is
// small enough, let's go ahead and snapshot test the whole thing
expect(workerBundleWithConstantData).toMatchInlineSnapshot(`
"------formdata-undici-0.test
Content-Disposition: form-data; name=\\"metadata\\"

{\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
------formdata-undici-0.test
Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
Content-Type: application/javascript+module

// _worker.js
var worker_default = {
async fetch(request, env) {
const url = new URL(request.url);
return url.pathname.startsWith(\\"/api/\\") ? new Response(\\"Ok\\") : env.ASSETS.fetch(request);
}
};
export {
worker_default as default
};
//# sourceMappingURL=bundledWorker-0.test.mjs.map
"------formdata-undici-0.test
Content-Disposition: form-data; name=\\"metadata\\"

------formdata-undici-0.test--"
`);
{\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
------formdata-undici-0.test
Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
Content-Type: application/javascript+module

// public/_worker.js
var worker_default = {
async fetch(request, env) {
const url = new URL(request.url);
return url.pathname.startsWith(\\"/api/\\") ? new Response(\\"Ok\\") : env.ASSETS.fetch(request);
}
};
export {
worker_default as default
};
//# sourceMappingURL=bundledWorker-0.test.mjs.map

------formdata-undici-0.test--"
`);

return HttpResponse.json(
{
Expand Down Expand Up @@ -5260,7 +5260,7 @@ Failed to publish your Function. Got error: Uncaught TypeError: a is not a funct
expect(contents).toContain(
'Content-Disposition: form-data; name="functionsWorker-0.test.js.map"'
);
expect(contents).toContain('"sources":["[[path]].ts"');
expect(contents).toContain('"sources":["functions/[[path]].ts",');
});

await runWrangler("pages deploy");
Expand All @@ -5284,7 +5284,7 @@ Failed to publish your Function. Got error: Uncaught TypeError: a is not a funct
expect(contents).toContain(
'Content-Disposition: form-data; name="bundledWorker-0.test.mjs.map"'
);
expect(contents).toContain('"sources":["_worker.js"');
expect(contents).toContain('"sources":["dist/_worker.js"]');
});

await runWrangler("pages deploy");
Expand Down
Loading
Loading