fix(storybook): disable Vite publicDir to stop static copy race#6482
fix(storybook): disable Vite publicDir to stop static copy race#6482blunteshwar wants to merge 2 commits into
Conversation
`storybook build` copied `public/` into `storybook-static/` twice concurrently: once via Storybook's `staticDirs: ['../public']` and again via Vite's default `publicDir` (builder-vite sets Vite `root` to the package dir and never sets `publicDir`, so it defaults to `<root>/public`, the same folder). Both copies run in one `Promise.all`, and node's `cp` recurses with a non-recursive `mkdir(dest)` per directory, so the two copiers race and the loser throws `EEXIST` on a nested dir (e.g. `.well-known/agent-skills/.../guides`). The large generated agent-skills tree widened the window, making the "Build second-gen Storybook" step fail intermittently in preview-docs and publish-2ndgen-docs. Set `publicDir: false` in `viteFinal` so Storybook's `staticDirs` copy is the single writer. Dev serving is unaffected (statics are served via middleware, not Vite's publicDir). Verified locally on Node 24.11.1: build succeeds, no EEXIST, and `.well-known/agent-skills` is present in the output.
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Description
The 2nd-gen Build second-gen Storybook step (
yarn workspace @adobe/spectrum-wc storybook:build) fails intermittently with:Root cause:
storybook buildcopiespublic/intostorybook-static/twice, concurrently:staticDirs: ['../public']copy (copyAllStaticFilesRelativeToMain).publicDir.builder-vitesets Viteroot = resolve(configDir, '..')(the package dir) and never setspublicDir, so Vite defaults to<root>/public— the same folder.Both copies run inside a single
Promise.all([viteBuild, staticDirsCopy]). Node'scprecurses sequentially and issues a non-recursiveawait mkdir(dest)per directory, so when the two copiers reach the same nested directory the loser throwsEEXIST. Timing-dependent, hence flaky. The large generated.well-known/agent-skillstree (yarn generate:skills, added in #6423) widened the collision window, which is why the failures started appearing.The fix sets
publicDir: falseinviteFinal, so Storybook'sstaticDirscopy is the single writer ofpublic/and there is no second, racing copier.Motivation and context
Intermittent red builds on the docs-deployment path (
preview-docs.ymlandpublish-2ndgen-docs.yml, both of which callstorybook:build) block unrelated PRs and force manual reruns. This removes the race at its source rather than papering over it with a retry.Reproduction (two concurrent copies of
public/into one destination) throwsEEXIST40/40 on Node v24.11.1; a single copy never does.Related issue(s)
preview-docsrun.Screenshots (if appropriate)
n/a — build configuration change, no visual output.
Author's checklist
storybook:buildrun on Node 24.11.1, see below.).storybook/main.tsis build tooling and is not published.)Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
2nd-gen Storybook builds cleanly and serves generated statics
yarn workspace @adobe/spectrum-wc storybook:buildon Node 24.11.1.EEXISTerror.2nd-gen/packages/swc/storybook-static/.well-known/agent-skills/index.jsonand.well-known/agent-skills/spectrum-web-components/references/guides/exist in the output.Dev server still serves statics
yarn workspace @adobe/spectrum-wc storybook(dev)./.well-known/agent-skills/index.jsonand confirm it is served (dev statics come from middleware, not Vite's publicDir, so this path is unaffected).Device review
Accessibility testing checklist
This change only affects how Storybook copies static files during the build; it renders no component markup and changes no DOM.
Keyboard
Screen reader
Verification
Verified locally on Node v24.11.1 (repo
.nvmrc):storybook:buildcompletes with exit 0 and zeroEEXISTerrors.storybook-static/index.htmlis present (preview build intact).storybook-static/.well-known/agent-skills/…/references/guides/is fully populated (statics still copied viastaticDirs).