[wrangler] fix: handle deleted entry point during hot-reload without unhandled rejection#13838
Conversation
🦋 Changeset detectedLatest commit: fa47c9f 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 |
There was a problem hiding this comment.
Pull request overview
This PR improves wrangler dev hot-reload resilience by preventing a synchronous readFileSync() failure (when the worker entrypoint is deleted/moved between rebuilds) from being promoted into an unhandled promise rejection that crashes the process.
Changes:
- Wraps
readFileSync(previousBundle.path, "utf8")in atry/catchduring rebuild updates and logs a warning on failure. - Skips applying the rebuild update when the entrypoint can’t be read (intended to keep the dev session alive).
- Adds a changeset to ship the fix as a patch release.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
packages/wrangler/src/dev/use-esbuild.ts |
Adds error handling + warning log around reading the previous bundle entrypoint during rebuild updates. |
.changeset/fix-unhandled-rejection-esbuild-entry-deleted.md |
Declares a patch changeset describing the dev hot-reload crash fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… mutation on failure
|
@NuroDev @penalosa @dario-piotrowicz — all Copilot review comments have been addressed. This PR is ready for review. |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
bfd2ac8 to
9df1c4a
Compare
|
The Windows CI failure is unrelated to this PR's changes. What failed: What this PR touches: only This looks like a known flaky Windows browser/CDP test (browser session not starting in time on slow Windows runners). Could a maintainer re-run the failed jobs? 🙏 |
|
CI failure (Tests, Windows, packages-and-tools) is the same pre-existing miniflare browser plugin flake — browser session times out on the Windows runner. Unrelated to the hot-reload entrypoint fix. Could a maintainer re-run the failed job? |
Fixes #13122.
During
wrangler dev, if the worker entry point is deleted or moved between builds, thereadFileSynccall inside theupdateBundlecallback throws synchronously and is promoted to an unhandled promise rejection, crashing the process.Fix: Wrap the
readFileSynccall in a try/catch. On failure, log a warning and return the previous bundle unchanged, so the dev session stays alive.