-
Notifications
You must be signed in to change notification settings - Fork 1k
[wrangler] Prevent concurrent custom builds when multiple files change #10955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[wrangler] Prevent concurrent custom builds when multiple files change #10955
Conversation
- Improve debounce utility to support generic function signatures with parameters - Apply debounce to custom build watcher with 50ms delay to prevent concurrent builds - Fixes #10944 Co-Authored-By: [email protected] <[email protected]>
🤖 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: 5e714a8 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 |
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: |
* function was invoked. | ||
*/ | ||
export function debounce(fn: () => void, delayMs = 100) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use any
. Try unknown
?
Thanks for the suggestion! I tried using When a type parameter appears in a function parameter position (contravariant), TypeScript's subtyping rules are reversed. With The build error we get is:
Using For reference: TypeScript Handbook on Contravariance |
Fixes #10944
When using custom builds with file watching, if multiple files changed simultaneously (e.g., via git operations or editor auto-saves), the build would trigger multiple times concurrently. This PR fixes the issue by debouncing the custom build trigger with a 50ms delay.
Changes
Enhanced the
debounce
utility (packages/wrangler/src/utils/debounce.ts
) to support generic function signatures with parameters:() => void
functionsany[]
with eslint-disable (necessary for TypeScript contravariance)Applied debounce to custom build watcher (
packages/wrangler/src/api/startDevWorker/BundlerController.ts
):#runCustomBuild
callback with debounced versionpages/dev.ts
pattern)Review Focus
#runCustomBuild
Link to Devin run: https://app.devin.ai/sessions/0923b0d7ecc441d29357b877d08d1d63
Requested by: @smacleod
pages/dev.ts
); the logic correctness is straightforward and can be verified through code review