Skip to content

Commit ab124d9

Browse files
committed
Update based on PR feedback
1 parent c2ce101 commit ab124d9

File tree

3 files changed

+19
-98
lines changed

3 files changed

+19
-98
lines changed

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

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -4446,88 +4446,6 @@ addEventListener('fetch', event => {});`
44464446
`);
44474447
});
44484448

4449-
it("should warn when using smart placement with assets-first", async () => {
4450-
const assets = [
4451-
{ filePath: ".assetsignore", content: "*.bak\nsub-dir" },
4452-
{ filePath: "file-1.txt", content: "Content of file-1" },
4453-
{ filePath: "file-2.bak", content: "Content of file-2" },
4454-
{ filePath: "file-3.txt", content: "Content of file-3" },
4455-
{ filePath: "sub-dir/file-4.bak", content: "Content of file-4" },
4456-
{ filePath: "sub-dir/file-5.txt", content: "Content of file-5" },
4457-
];
4458-
writeAssets(assets, "assets");
4459-
writeWranglerConfig({
4460-
assets: {
4461-
directory: "assets",
4462-
experimental_serve_directly: true,
4463-
},
4464-
placement: {
4465-
mode: "smart",
4466-
},
4467-
});
4468-
const bodies: AssetManifest[] = [];
4469-
await mockAUSRequest(bodies);
4470-
mockSubDomainRequest();
4471-
mockUploadWorkerRequest({
4472-
expectedAssets: {
4473-
jwt: "<<aus-completion-token>>",
4474-
config: {
4475-
serve_directly: true,
4476-
},
4477-
},
4478-
expectedType: "none",
4479-
});
4480-
4481-
await runWrangler("deploy");
4482-
4483-
expect(std.warn).toMatchInlineSnapshot(`
4484-
"▲ [WARNING] Using assets with smart placement turned on may result in poor performance.
4485-
4486-
"
4487-
`);
4488-
});
4489-
4490-
it("should warn when using smart placement with assets-first", async () => {
4491-
const assets = [
4492-
{ filePath: ".assetsignore", content: "*.bak\nsub-dir" },
4493-
{ filePath: "file-1.txt", content: "Content of file-1" },
4494-
{ filePath: "file-2.bak", content: "Content of file-2" },
4495-
{ filePath: "file-3.txt", content: "Content of file-3" },
4496-
{ filePath: "sub-dir/file-4.bak", content: "Content of file-4" },
4497-
{ filePath: "sub-dir/file-5.txt", content: "Content of file-5" },
4498-
];
4499-
writeAssets(assets, "assets");
4500-
writeWranglerConfig({
4501-
assets: {
4502-
directory: "assets",
4503-
experimental_serve_directly: true,
4504-
},
4505-
placement: {
4506-
mode: "smart",
4507-
},
4508-
});
4509-
const bodies: AssetManifest[] = [];
4510-
await mockAUSRequest(bodies);
4511-
mockSubDomainRequest();
4512-
mockUploadWorkerRequest({
4513-
expectedAssets: {
4514-
jwt: "<<aus-completion-token>>",
4515-
config: {
4516-
serve_directly: true,
4517-
},
4518-
},
4519-
expectedType: "none",
4520-
});
4521-
4522-
await runWrangler("deploy");
4523-
4524-
expect(std.warn).toMatchInlineSnapshot(`
4525-
"▲ [WARNING] Using assets with smart placement turned on may result in poor performance.
4526-
4527-
"
4528-
`);
4529-
});
4530-
45314449
it("should warn if experimental_serve_directly=false but no binding is provided", async () => {
45324450
const assets = [
45334451
{ filePath: ".assetsignore", content: "*.bak\nsub-dir" },
@@ -4562,13 +4480,18 @@ addEventListener('fetch', event => {});`
45624480
await runWrangler("deploy");
45634481

45644482
expect(std.warn).toMatchInlineSnapshot(`
4565-
"▲ [WARNING] experimental_serve_directly=false but no assets.binding provided.
4483+
"▲ [WARNING] experimental_serve_directly=false set without an assets binding
4484+
4485+
Setting experimental_serve_directly to false will always invoke your Worker script.
4486+
To fetch your assets from your Worker, please set [assets.binding] in your configuration file.
4487+
4488+
Read more: https://developers.cloudflare.com/workers/static-assets/binding/#binding
45664489
45674490
"
45684491
`);
45694492
});
45704493

4571-
it("should error if an experimental_serve_directly is false without providing a user Worker", async () => {
4494+
it("should error if experimental_serve_directly is false and no user Worker is provided", async () => {
45724495
writeWranglerConfig({
45734496
assets: {
45744497
directory: "xyz",

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,13 +1720,18 @@ describe.sequential("wrangler dev", () => {
17201720
await runWranglerUntilConfig("dev");
17211721

17221722
expect(std.warn).toMatchInlineSnapshot(`
1723-
"▲ [WARNING] experimental_serve_directly=false but no assets.binding provided.
1723+
"▲ [WARNING] experimental_serve_directly=false set without an assets binding
1724+
1725+
Setting experimental_serve_directly to false will always invoke your Worker script.
1726+
To fetch your assets from your Worker, please set [assets.binding] in your configuration file.
1727+
1728+
Read more: https://developers.cloudflare.com/workers/static-assets/binding/#binding
17241729
17251730
"
17261731
`);
17271732
});
17281733

1729-
it("should error if an experimental_serve_directly is false without providing a user Worker", async () => {
1734+
it("should error if experimental_serve_directly is false and no user Worker is provided", async () => {
17301735
writeWranglerConfig({
17311736
assets: { directory: "assets", experimental_serve_directly: false },
17321737
});

packages/wrangler/src/assets.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,7 @@ export function validateAssetsArgsAndConfig(
444444
);
445445
}
446446

447-
// Smart placement turned on when using assets
448-
if (
449-
config?.placement?.mode === "smart" &&
450-
config?.assets?.experimental_serve_directly
451-
) {
452-
logger.warn(
453-
"Using assets with smart placement turned on may result in poor performance."
454-
);
455-
}
456-
457-
// User worker ahead of assets, but no assets binding provided
447+
// User Worker ahead of assets, but no assets binding provided
458448
if (
459449
"legacy" in args
460450
? args.assets?.assetConfig?.serve_directly === false &&
@@ -463,7 +453,10 @@ export function validateAssetsArgsAndConfig(
463453
!config?.assets?.binding
464454
) {
465455
logger.warn(
466-
"experimental_serve_directly=false but no assets.binding provided."
456+
"experimental_serve_directly=false set without an assets binding\n" +
457+
"Setting experimental_serve_directly to false will always invoke your Worker script.\n" +
458+
"To fetch your assets from your Worker, please set [assets.binding] in your configuration file.\n\n" +
459+
"Read more: https://developers.cloudflare.com/workers/static-assets/binding/#binding"
467460
);
468461
}
469462

0 commit comments

Comments
 (0)