Skip to content

[wrangler] Keep wrangler preview --json output parseable for Workers with static assets - #16029

Open
carldaws wants to merge 5 commits into
cloudflare:mainfrom
carldaws:preview-json-assets
Open

carldaws wants to merge 5 commits into
cloudflare:mainfrom
carldaws:preview-json-assets

Conversation

@carldaws

@carldaws carldaws commented Oct 2, 2026 •

Copy link
Copy Markdown

Fixes #16028.

wrangler preview --json prints the preview and deployment as JSON, but for a Worker with static assets the asset upload's progress ("🌀 Building list of assets...", "✨ Read 1 file from the assets directory", …) is written to stdout first, so piping the output into jq or JSON.parse fails.

syncAssets now takes an options object with a json flag. In --json mode its progress is logged at debug level instead, so it stays available with WRANGLER_LOG=debug. Other callers are unchanged; deploy passes its dispatch namespace in the new options object.

The existing --json tests didn't catch this because mockConsoleMethods() captures console.info separately from console.log, while in Node both write to stdout. The new test asserts that nothing is logged at info level alongside the JSON.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: a bug fix to existing documented behaviour

Devin Review

@changeset-bot

changeset-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9a88d3f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
wrangler Patch
@cloudflare/deploy-helpers Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
@cloudflare/remote-bindings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Oct 2, 2026
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team October 2, 2026 13:45
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/quiet-preview-json-assets.md: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/deploy.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/helpers/assets.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/preview/preview.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/preview.test.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@16029

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16029

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16029

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@16029

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16029

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@16029

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@16029

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@16029

miniflare

npm i https://pkg.pr.new/miniflare@16029

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16029

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@16029

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16029

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@16029

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@16029

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16029

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@16029

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@16029

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@16029

wrangler

npm i https://pkg.pr.new/wrangler@16029

commit: 9a88d3f

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me, but there are a few small things that I'd love to see for the maintainability/clearness of the code, could you have a look @carldaws? 🙏

And thanks a lot for the PR! 🙏

@carldaws

carldaws commented Oct 6, 2026

Copy link
Copy Markdown
Author

@dario-piotrowicz thank you for your suggestions, I have applied them all :)

@carldaws

carldaws commented Oct 6, 2026

Copy link
Copy Markdown
Author

@dario-piotrowicz thanks for the review! I've finished the renames now, the suggestions only covered the lines you commented on, so the build broke in between.

Quick question on the ...logger spread: ProgressLogger is only info and log, and both are already set. Were you thinking of widening the return type to Logger? If so, error and loggerLevel are on the class prototype, so the spread wouldn't copy them, right? Happy to go either way.

@dario-piotrowicz

Copy link
Copy Markdown
Member

Thanks @carldaws 🙏

Yes, sorry the ...logger was my mistake, given the new type you're right it's totally unnecessary, could you revert that change? 😓

Besides that there's now a merge conflict here 😢, but other than that I think this PR is good to go 😄

@carldaws
carldaws force-pushed the preview-json-assets branch from 1588167 to 9a88d3f Compare October 8, 2026 16:14
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/quiet-preview-json-assets.md: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/deploy.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/helpers/assets.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/preview/preview.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/preview.test.ts: [@cloudflare/wrangler]

@carldaws

carldaws commented Oct 8, 2026 •

Copy link
Copy Markdown
Author

@dario-piotrowicz the spread is gone and the conflict is resolved 😄 could you rerun the failing CI step? I think it's a flake as I can't reproduce it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

wrangler preview --json output is not valid JSON for Workers with static assets

3 participants