Skip to content

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Oct 7, 2025

Fixes #10523 and fixes #5460

The linked issues raise a valid point that Wrangler by default does a lot of disk IO and leaves large log files sitting around on your system. One of the issues proposed a new option to turn off writing logs to disk, but I think we can actually go a bit further. This PR entirely disables writing logs to disk unless one of the following conditions are met:

  • The log file path has been customised from the default
  • Wrangler's log level (not the level of the individual message) is debug

My rationale is that log file support is primarily a debugging feature for the Wrangler team, and we only ask for log files with WRANGLER_LOG=debug turned on.


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: non functional performance optimisation

@penalosa penalosa requested a review from a team as a code owner October 7, 2025 23:38
Copy link

changeset-bot bot commented Oct 7, 2025

🦋 Changeset detected

Latest commit: 7b3bb78

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers 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

Copy link
Contributor

github-actions bot commented Oct 7, 2025

These changes have been automatically backported to Wrangler v3 🎉 You can view the automatically updated PR at v3-maintenance...v3-backport-10909. Please check that PR for correctness, and make sure it's merged after this one. Thank you for helping us keep Wrangler v3 supported!

Copy link

pkg-pr-new bot commented Oct 7, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10909

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 7b3bb78

@petebacondarwin
Copy link
Contributor

I believe the original reasoning behind this behaviour was to capture logs preemptively before the error occurs, even if you are not planning on dumping all the logs to the console. Then when you hit a bug (which could be transient) you have the logs available to diagnose the cause. With this change, that benefit is lost.

Also, the change to only store logs if the output is set to debug seems a bit redundant. If you are already dumping the logs to the output there is little point in additionally writing them to disk, right?

How about we have a rolling log that only stores the last X lines of debug output? This would keep the log file size down while still providing this diagnostic element.
Also how about we clean up old logs when running Wrangler (e.g. any logs over 24 hours old)? This would keep the number of log file stored down.

Copy link
Contributor

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

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

I find having logs when an unexpected error occurs fairly useful. Can we delete logs on a successful run maybe?

Edit: didn't see what pete said, but +1 to cleaning up old logs.

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 uses unbounded disk space for logs, no flag to disable 🚀 Feature Request: Log rotation

3 participants