diff --git a/.changeset/nice-chefs-hang.md b/.changeset/nice-chefs-hang.md new file mode 100644 index 000000000000..bc8d3523dad3 --- /dev/null +++ b/.changeset/nice-chefs-hang.md @@ -0,0 +1,7 @@ +--- +"wrangler": minor +--- + +feat: Tail Consumers are now supported for Workers with assets. + +You can now configure `tail_consumers` in conjunction with `assets` in your `wrangler.toml` file. Read more about [Static Assets](https://developers.cloudflare.com/workers/static-assets/) and [Tail Consumers](https://developers.cloudflare.com/workers/observability/logs/tail-workers/) in the documentation. diff --git a/packages/wrangler/src/__tests__/deploy.test.ts b/packages/wrangler/src/__tests__/deploy.test.ts index 2d96ce3dcef1..c9146ac6d870 100644 --- a/packages/wrangler/src/__tests__/deploy.test.ts +++ b/packages/wrangler/src/__tests__/deploy.test.ts @@ -4352,31 +4352,6 @@ addEventListener('fetch', event => {});` ); }); - it("should error if --assets and config.tail_consumers are used together", async () => { - writeWranglerToml({ - tail_consumers: [{ service: "" }], - }); - fs.mkdirSync("public"); - await expect( - runWrangler("deploy --assets public") - ).rejects.toThrowErrorMatchingInlineSnapshot( - `[Error: Cannot use assets and tail consumers in the same Worker. Tail Workers are not yet supported for Workers with assets.]` - ); - }); - - it("should error if config.assets and config.tail_consumers are used together", async () => { - writeWranglerToml({ - assets: { directory: "./public" }, - tail_consumers: [{ service: "" }], - }); - fs.mkdirSync("public"); - await expect( - runWrangler("deploy") - ).rejects.toThrowErrorMatchingInlineSnapshot( - `[Error: Cannot use assets and tail consumers in the same Worker. Tail Workers are not yet supported for Workers with assets.]` - ); - }); - it("should error if directory specified by flag --assets does not exist", async () => { await expect(runWrangler("deploy --assets abc")).rejects.toThrow( new RegExp( diff --git a/packages/wrangler/src/assets.ts b/packages/wrangler/src/assets.ts index a3fdc1d81369..2359b763123e 100644 --- a/packages/wrangler/src/assets.ts +++ b/packages/wrangler/src/assets.ts @@ -406,13 +406,6 @@ export function validateAssetsArgsAndConfig( ); } - // tail_consumers don't exist in dev, so ignore SDW here - if ((args.assets || config?.assets) && config?.tail_consumers?.length) { - throw new UserError( - "Cannot use assets and tail consumers in the same Worker. Tail Workers are not yet supported for Workers with assets." - ); - } - const noOpEntrypoint = path.resolve( getBasePath(), "templates/no-op-worker.js"