diff --git a/packages/wrangler/src/__tests__/deploy.test.ts b/packages/wrangler/src/__tests__/deploy.test.ts index 9fefab75f9ae..0e092052c8f6 100644 --- a/packages/wrangler/src/__tests__/deploy.test.ts +++ b/packages/wrangler/src/__tests__/deploy.test.ts @@ -4446,6 +4446,47 @@ addEventListener('fetch', event => {});` `); }); + it("should warn when using smart placement with Worker first", async () => { + const assets = [ + { filePath: ".assetsignore", content: "*.bak\nsub-dir" }, + { filePath: "file-1.txt", content: "Content of file-1" }, + { filePath: "file-2.bak", content: "Content of file-2" }, + { filePath: "file-3.txt", content: "Content of file-3" }, + { filePath: "sub-dir/file-4.bak", content: "Content of file-4" }, + { filePath: "sub-dir/file-5.txt", content: "Content of file-5" }, + ]; + writeAssets(assets, "assets"); + writeWranglerConfig({ + assets: { + directory: "assets", + experimental_serve_directly: false, + }, + placement: { + mode: "smart", + }, + }); + const bodies: AssetManifest[] = []; + await mockAUSRequest(bodies); + mockSubDomainRequest(); + mockUploadWorkerRequest({ + expectedAssets: { + jwt: "<>", + config: { + serve_directly: true, + }, + }, + expectedType: "none", + }); + + await runWrangler("deploy"); + + expect(std.warn).toMatchInlineSnapshot(` + "▲ [WARNING] Using assets with smart placement enabled may result in poor performance. + + " + `); + }); + it("should warn if experimental_serve_directly=false but no binding is provided", async () => { const assets = [ { filePath: ".assetsignore", content: "*.bak\nsub-dir" }, diff --git a/packages/wrangler/src/assets.ts b/packages/wrangler/src/assets.ts index 35bfa5de6d06..c565bbccb234 100644 --- a/packages/wrangler/src/assets.ts +++ b/packages/wrangler/src/assets.ts @@ -444,6 +444,16 @@ export function validateAssetsArgsAndConfig( ); } + // Smart placement turned on when using assets + if ( + config?.placement?.mode === "smart" && + config?.assets?.experimental_serve_directly === false + ) { + logger.warn( + "Using assets with smart placement enabled may result in poor performance." + ); + } + // User Worker ahead of assets, but no assets binding provided if ( "legacy" in args