storybookjs/storybook

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

Open

#30665 opened on Feb 25, 2025

View on GitHub
 (1 comment) (1 reaction) (0 assignees)TypeScript (89,909 stars) (10,058 forks)batch import
bugcorehelp wanted

Description

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.

https://github.com/storybookjs/storybook/blob/f2af1732a389ac2f55dbb95f892eed45f44f015d/code/core/src/common/utils/file-cache.ts#L97

https://github.com/storybookjs/storybook/blob/f2af1732a389ac2f55dbb95f892eed45f44f015d/code/core/src/common/utils/file-cache.ts#L89

https://github.com/storybookjs/storybook/blob/f2af1732a389ac2f55dbb95f892eed45f44f015d/code/core/src/builder-manager/utils/files.ts#L23

https://github.com/storybookjs/storybook/blob/f2af1732a389ac2f55dbb95f892eed45f44f015d/code/core/src/csf-tools/ConfigFile.ts#L971

https://github.com/storybookjs/storybook/blob/f2af1732a389ac2f55dbb95f892eed45f44f015d/code/builders/builder-vite/src/plugins/external-globals-plugin.ts#L67

https://github.com/storybookjs/storybook/blob/f2af1732a389ac2f55dbb95f892eed45f44f015d/code/lib/create-storybook/src/generators/configure.ts#L114

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

Contributor guide