fix(wrangler): emit an error event for watch-mode rebuild failures - #14561
Conversation
Initial build failures route through the BundlerController's error event, so DevEnv logs them and emits `buildFailed` — but watch-mode rebuild failures were only logged from the log-build-output esbuild plugin and never became events, leaving startWorker consumers unable to observe a broken rebuild (only initial builds and config parse errors fired `buildFailed`). The plugin gains an optional `onRebuildError` callback that takes ownership of the failure (including its logging) when provided; runBuild threads it, and the BundlerController routes rebuild failures through emitErrorEvent with the esbuild messages as a BuildFailure- shaped cause — DevEnv's existing handling then logs via logBuildFailure exactly as before (no double-logging) and emits `buildFailed` symmetrically with initial builds. Existing logBuildOutput callers are unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 69e1bee The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers |
@cloudflare/autoconfig
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
The change makes sense to me. Rebuild failures should be observable like initial build failures. What are you using For context, we are likely going to steer users toward |
I've been building my own daemon that coordinates typecheck, lint, tests, and dev servers for a worktree, and turns output into compact, diffed, actionable evidence (e.g. answering "What diagnostics changed as a result of the latest edits?", "What errors occurred since the last dev server reload?"). It's mainly meant for agents, because it avoids having them run different tools and repeatedly bring raw output into the context to interpret.
For testing, we're already on The Vite plugin may be able to replace
If those sound like additions that would be helpful to more people, I'm happy to take a stab at it and open a PR. |
|
I will need to discuss this with my team further. But the list looks reasonable to me. I am gonna merge the PR first. Thanks for the fix! |
Thanks! Note that #14562 is related to this, but it's not as straightforward a fix, so it may need more scrutiny. |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
When
unstable_startWorkerruns in watch mode and a rebuild fails, thelogBuildOutputesbuild plugin logs the failure and swallows it — no error event is dispatched, so programmatic consumers cannot observe that dev is now serving the previous bundle. Initial build failures, by contrast, route through the error path and surface asbuildFailedon the DevEnv.This threads an optional
onRebuildError(errors, warnings)callback throughlogBuildOutput/runBuild;BundlerControllerprovides it and routes rebuild failures through the same error path as initial-build failures, attaching the esbuild messages as the errorcause. Terminal output is unchanged (the error path still logs vialogBuildFailure),buildFailednow fires symmetrically, and recovery is unaffected (the next successful rebuild emitsreloadCompleteas before).unstable_startWorkeris an experimental API; a changeset is included.🤖 Generated with Claude Code