Skip to content

CLI: Lock language pack setup#3492

Open
chubes4 wants to merge 1 commit into
trunkfrom
fix/language-pack-setup-race
Open

CLI: Lock language pack setup#3492
chubes4 wants to merge 1 commit into
trunkfrom
fix/language-pack-setup-race

Conversation

@chubes4
Copy link
Copy Markdown
Contributor

@chubes4 chubes4 commented May 14, 2026

Related issues

Proposed Changes

Concurrent CLI invocations can all run setupServerFiles() and refresh ~/.studio/server-files/language-packs at the same time. When one process removes the shared target tree while another is copying or preserving timestamps, the losing process prints transient ENOENT setup warnings even though the requested WP-CLI command completes.

This PR serializes the language-pack refresh with Studio's existing lockfile helper, and reruns the size/mtime comparison inside the lock so only the first process refreshes the cache while later processes skip once the cache is current.

Evidence

Reproduction used a disposable DEV_CONFIG_DIR with a stale language-pack cache, then ran 24 concurrent studio wp --studio-no-path cli version requests.

Before this fix, the repro produced multiple setup warnings while still completing WP-CLI:

Failed to set up dependency language packs: Error: ENOENT: no such file or directory, lstat '.../server-files/language-packs/es_ES-81d6f084cb273e02e15b01bd9ece87f7.json'
  code: 'ENOENT',
WP-CLI 2.12.0

I also forced target deletion during copy and reproduced the narrower utime variant:

Failed to set up dependency language packs: Error: ENOENT: no such file or directory, utime '.../server-files/language-packs/admin-id_ID.l10n.php'
  code: 'ENOENT',
  syscall: 'utime',
WP-CLI 2.12.0

After this fix, the same concurrent stale-cache repro against the patched built CLI completed cleanly:

warning_matches=0
wp_cli_successes=      24

Testing Instructions

  1. npm run cli:build
  2. npm test -- apps/cli/lib/dependency-management/tests/setup.test.ts
  3. npx eslint apps/cli/lib/dependency-management/setup.ts
  4. Run the concurrent repro from studio wp can print language-pack ENOENT warnings during concurrent setup #3489 against node apps/cli/dist/cli/main.mjs wp --studio-no-path cli version and verify there are no Failed to set up dependency language packs warnings.

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (GPT-5.5)
  • Used for: Investigating the race, drafting the fix, running verification commands, and drafting this PR description. Chris remains responsible for review and validation.

@wpmobilebot
Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 07b5409 vs trunk

app-size

Metric trunk 07b5409 Diff Change
App Size (Mac) 1409.62 MB 1409.62 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 07b5409 Diff Change
load 1475 ms 1502 ms +27 ms ⚪ 0.0%

site-startup

Metric trunk 07b5409 Diff Change
siteCreation 8556 ms 8550 ms 6 ms ⚪ 0.0%
siteStartup 4927 ms 4939 ms +12 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

studio wp can print language-pack ENOENT warnings during concurrent setup

2 participants