Prevent concurrent wrangler dev instances from fighting over the skills-install prompt#14199
Prevent concurrent wrangler dev instances from fighting over the skills-install prompt#14199dario-piotrowicz wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 818496c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
|
✅ All changesets look good |
|
Review posted successfully to PR #14199 with a summary and two inline suggestion comments (fd leak fix + stale-marker liveness check), plus a ranked list of the three issues found. |
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
@cloudflare/wrangler-bundler
commit: |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
petebacondarwin
left a comment
There was a problem hiding this comment.
This feature is getting pretty complex! Is there some way we could simplify the whole approach? In my mind I feel like we could just say: the question is only ever shown once, whether or not it is answered. We can just write a "no" answer into the metadata file before we even ask the question; if the user decides to say yes, we overwrite it with a "yes". Then if a second Wrangler starts up while the first is showing the question, it will not ask the question since it thinks it has already been answered. This would also avoid the Ctrl-C problem too.
Fixes the concurrency bug described in #14116 (comment)
When two
wrangler devprocesses start in parallel, both could reach the interactive "Install Cloudflare skills?" prompt simultaneously. The second process's TTY output would overwrite the first's interactive prompt, making it invisible and unresponsive to the user.A collision-detection mechanism now prevents this using the metadata JSONC file itself as a lock. Before showing the prompt, each process atomically creates the metadata file with a pending marker containing its PID and waits a 500 ms grace period. If a second process starts during that window, it overwrites the marker with its own PID and skips. The first process detects the PID change after the grace period and also skips. This ensures the prompt is only shown when a single
wrangler devinstance is running. Stale pending markers (older than 60 seconds, e.g. from a crashed process) are automatically cleaned up.A picture of a cute animal (not mandatory, but encouraged)