Skip to content

[wrangler] fix: handle deleted entry point during hot-reload without unhandled rejection#13838

Merged
petebacondarwin merged 3 commits into
cloudflare:mainfrom
matingathani:fix/unhandled-rejection-esbuild-entry-deleted
Jun 15, 2026
Merged

[wrangler] fix: handle deleted entry point during hot-reload without unhandled rejection#13838
petebacondarwin merged 3 commits into
cloudflare:mainfrom
matingathani:fix/unhandled-rejection-esbuild-entry-deleted

Conversation

@matingathani

Copy link
Copy Markdown
Contributor

Fixes #13122.

During wrangler dev, if the worker entry point is deleted or moved between builds, the readFileSync call inside the updateBundle callback throws synchronously and is promoted to an unhandled promise rejection, crashing the process.

Fix: Wrap the readFileSync call in a try/catch. On failure, log a warning and return the previous bundle unchanged, so the dev session stays alive.


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: internal dev-mode error handling, no user-facing API change

Copilot AI review requested due to automatic review settings May 7, 2026 00:30
@changeset-bot

changeset-bot Bot commented May 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 801090b

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

@workers-devprod workers-devprod requested review from a team and penalosa and removed request for a team May 7, 2026 00:31
@workers-devprod

workers-devprod commented May 7, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

This comment was marked as resolved.

@matingathani

Copy link
Copy Markdown
Contributor Author

@NuroDev @penalosa @dario-piotrowicz — all Copilot review comments have been addressed. This PR is ready for review.

Comment thread packages/wrangler/src/dev/use-esbuild.ts Outdated

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk May 7, 2026
@pkg-pr-new

pkg-pr-new Bot commented May 7, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/create-cloudflare@13838

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/deploy-helpers@13838

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/kv-asset-handler@13838

miniflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/miniflare@13838

@cloudflare/pages-shared

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/pages-shared@13838

@cloudflare/unenv-preset

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/unenv-preset@13838

@cloudflare/vite-plugin

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/vite-plugin@13838

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

npm i https://pkg.pr.new/cloudflare/workers-sdk/wrangler@13838

@cloudflare/wrangler-bundler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/wrangler-bundler@13838

commit: 801090b

@matingathani matingathani force-pushed the fix/unhandled-rejection-esbuild-entry-deleted branch from bfd2ac8 to 9df1c4a Compare May 11, 2026 02:17
@matingathani

Copy link
Copy Markdown
Contributor Author

The Windows CI failure is unrelated to this PR's changes.

What failed: packages/miniflare/test/plugins/browser/index.spec.ts — 9 browser plugin tests timed out or got SyntaxError: Unexpected token 'E', "Error: The"... is not valid JSON from entry.worker.js.

What this PR touches: only packages/wrangler/src/dev/use-esbuild.ts and a changeset file.

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? 🙏

@matingathani

Copy link
Copy Markdown
Contributor Author

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?

@matingathani

Copy link
Copy Markdown
Contributor Author

This is approved and CI is green — could a maintainer merge when convenient? Thanks!

@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@matingathani matingathani force-pushed the fix/unhandled-rejection-esbuild-entry-deleted branch from 33f0eca to 801090b Compare June 3, 2026 09:16
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/wrangler/src/dev/use-esbuild.ts
@matingathani

Copy link
Copy Markdown
Contributor Author

This is approved by @penalosa with clean CI — could a maintainer merge when ready?

@petebacondarwin petebacondarwin merged commit 208b3bb into cloudflare:main Jun 15, 2026
58 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Unhandled rejection when worker entry point is deleted during rebuild

5 participants