Skip to content
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

[Bug]: Storybook cache is unstable and should be thoroughly analyzed to account for file system errors. #30665

Open
mattsteve opened this issue Feb 25, 2025 · 1 comment

Comments

@mattsteve
Copy link

mattsteve commented Feb 25, 2025

Describe the bug

We've had this problem for a very long time. I suspect because McAfee Solidifier (unfortunately) is running on our work PCs and aggressively checks files as they are created (preventing write locks). Basically filesystem writes in the cache folder can randomly fail with "OPEN" errors. And by randomly, I mean about every 1-5 times I save a file in our project.

We previously got around this in Storybook 6 by disabling caching through webpack configuration. But there is no way in Storybook 8 to disable the core/src/common/utils/file-cache.ts, which is causing the storybook server to constantly and frequently crash.

I have looked through the codebase, and honesly I am very disappointed at how little thought has gone into filesystem access. You should be treating your filesystem reads and writes like they can fail 20% of the time, and properly handle these error scenarios. Even if 20% is unrealistic, the purpose is to harden your program so you're not running into random filesystem bugs. Especially for something like caching which is not mission critical for the software to run.

Here are some examples I found of unchecked filesystem writes. The errors aren't caught and handled, and usually any sort of write error causes a crash.

writeFileSync(this.generateHash(name), this.parseSetData(name, data, opts), {

await writeFile(this.generateHash(name), this.parseSetData(name, data, opts), {

await writeFile(location, file.contents);

await writeFile(fname, formatConfig(config));

await writeFile(externalCachePath, `module.exports = ${externals[externalKey]};`);

await writeFile(mainPath, mainJsContents, { encoding: 'utf8' });

You call this project the industry standard, please write your code so that it lives up to this title.

Reproduction link

https://stackblitz.com/github/storybookjs/sandboxes/tree/next/vue3-vite/default-ts/after-storybook?file=README.md&preset=node

Reproduction steps

  1. Run a basic Vue / Typscript / Webpack 5 storybook app.
  2. Save a couple of times.
  3. Storybook crashes.

System

Image

Additional context

No response

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Feb 25, 2025

Hi @mattsteve

Thank you for opening the issue and for the analysis.

Please feel free to pick up the work and contribute a PR, since the solution seems to be pretty straightforward. I am happy to assist at any time if questions arise.

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

No branches or pull requests

2 participants