Skip to content

Commit

Permalink
Add support for Tail Consumers with Assets (#7201)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregBrimble authored Nov 12, 2024
1 parent ce3cccc commit beed72e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .changeset/nice-chefs-hang.md
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 0 additions & 25 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4352,31 +4352,6 @@ addEventListener('fetch', event => {});`
);
});

it("should error if --assets and config.tail_consumers are used together", async () => {
writeWranglerToml({
tail_consumers: [{ service: "<TAIL_WORKER_NAME>" }],
});
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: "<TAIL_WORKER_NAME>" }],
});
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(
Expand Down
7 changes: 0 additions & 7 deletions packages/wrangler/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit beed72e

Please sign in to comment.