Skip to content

Fix flaky site duplication by tolerating transient files deleted mid-copy - #4074

Merged
youknowriad merged 1 commit into
trunkfrom
claude/jolly-mestorf-e2ba3e
Jul 3, 2026
Merged

Fix flaky site duplication by tolerating transient files deleted mid-copy#4074
youknowriad merged 1 commit into
trunkfrom
claude/jolly-mestorf-e2ba3e

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude Code investigated the flaky duplicates a site from site settings e2e failure, traced the duplicate-site flow end to end to find the root cause, and wrote the fix and test changes. The analysis and diff were reviewed and scoped by the author (the standalone unit regression tests were dropped on review).

Proposed Changes

The duplicates a site from site settings e2e test (added in #4034) failed intermittently in CI: the sidebar showed the copied site, but cli.json never contained it. The investigation surfaced a real product race rather than a test-only timing issue:

  • Duplicating a site copies its directory while the site is running. A running Playground site continuously creates and deletes transient files (SQLite journal files, cache, cron activity). If one of them disappears between directory enumeration and the copy of that entry, the whole duplication fails with ENOENT and the user gets the "Failed to copy site" dialog. recursiveCopyDirectory now skips entries that vanish mid-copy — the same result a copy started a moment later would produce — so duplicating a running site no longer fails randomly. A missing top-level source still throws.
  • The e2e test masked that failure: the renderer optimistically shows the copy in the sidebar before the backend does any work, and on failure the content area falls back to the original (running) site, satisfying the unscoped "Running" assertion. Both duplicate tests now poll cli.json (the source of truth) for the copied site instead of sampling it once, so a genuine failure is reported at the right step with a clear message.

Testing Instructions

  • Create a site and leave it running, then use Settings → Duplicate site repeatedly; the duplication should succeed every time even while the source site is actively serving requests.
  • Run the e2e suite: npm run e2e -- sites.test.ts — the two duplication tests should pass.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

🤖 Generated with Claude Code

…copy

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@youknowriad

Copy link
Copy Markdown
Contributor Author

I run this test 5 times locally, all passing now.

@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 060c937 vs trunk

app-size

Metric trunk 060c937 Diff Change
App Size (Mac) 1345.38 MB 1317.43 MB 27.95 MB 🟢 -2.1%

site-editor

Metric trunk 060c937 Diff Change
load 1114 ms 734 ms 380 ms 🟢 -34.1%

site-startup

Metric trunk 060c937 Diff Change
siteCreation 6514 ms 6513 ms 1 ms ⚪ 0.0%
siteStartup 1867 ms 1862 ms 5 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

@youknowriad
youknowriad merged commit d9b6010 into trunk Jul 3, 2026
12 checks passed
@youknowriad
youknowriad deleted the claude/jolly-mestorf-e2ba3e branch July 3, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants