[wrangler] Display build errors for auxiliary workers in multi-worker mode#13136
Conversation
… mode When running wrangler dev with multiple -c config flags, build errors from auxiliary/secondary workers were only logged at debug level, causing Wrangler to silently hang. Build errors from BundlerController are now handled as recoverable errors and logged at error level. Fixes #13129 Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: d760e83 The changes in this PR will be included in the next version bump. 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 |
|
✅ All changesets look good |
|
The After thorough review, this is a clean, well-scoped bug fix:
LGTM |
|
Codeowners approval required for this PR:
Show detailed file reviewers |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
…evEnv Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
…er before emitErrorEvent() Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
dario-piotrowicz
left a comment
There was a problem hiding this comment.
LGTM with a small comment
Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
…-imports Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
Fixes #13129.
When running
wrangler devwith multiple-cconfig flags (multi-worker mode), build errors from auxiliary/secondary workers were only logged at debug level. This caused Wrangler to silently hang because theMultiworkerRuntimeControllernever received abundleCompleteevent for the failing worker, so#canStartMiniflare()never returned true.The fix centralizes build error logging in
DevEnv.handleErrorEvent():DevEnv.ts— Added a new branch that treatsBundlerControllererrors as recoverable (likeParseErrorfromConfigController). For esbuildBuildFailureerrors, it useslogBuildFailure()to produce the same nicely-formatted output (with source locations, notes, and suggestions) that the primary worker already gets viahandleError(). For non-esbuild bundler errors, it falls back to logging the error message.BundlerController.ts— Removed the 5logger.error()calls that preceded eachemitErrorEvent()call. Previously these caused double-logging because both BundlerController and the DevEnv error handler would log the same error. Error display is now solely handled by DevEnv, which is the central event dispatcher.This applies to all workers (primary and auxiliary), ensuring build errors are always visible, well-formatted, and logged exactly once.
Important review considerations
logger.error()calls were removed from BundlerController at 5 sites (custom build failure, tmp dir creation, startCustomBuild catch, startBundle catch, ensureWatchingAssets catch). The#startBundlerunBuilderror callback never had alogger.error()call, so it was already consistent with this approach.EventEmitter—BundlerControllererrors are now handled directly rather than falling through tothis.emit("error", event).event.cause.message. Theevent.reason(e.g. "Custom build failed") is still logged at debug level by the constructor listener. If richer context is desired for non-esbuild errors, the fallback could be adjusted.#canStartMiniflare()requires all workers), but the error is now visible so the user knows what to fix.Human review checklist
emitErrorEventinBundlerControllerreachDevEnv.handleErrorEvent()— removal of thelogger.error()calls relies on thisBundlerControllererrors being re-emitted viathis.emit("error", event)on theDevEnvEventEmitter (they now get handled inline instead)isBuildFailure/isBuildFailureFromCausetype guards correctly detect all esbuild error shapes thatBundlerControllercan produceLink to Devin session: https://app.devin.ai/sessions/ddf3cd9d12e941feb73d87d26da8d1ec
Requested by: @petebacondarwin