-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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]: vite builder fails trying to optimize files in the storybook cache folder #28542
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
@timmevandermeer unfortunately it will be difficult for us to investigate this without a reproduction. Are you able to narrow down which dependency is the problematic one? It will also be helpful to see your storybook dependencies. |
@vanessayuenn I understand but the issue occurs in a seemingly unpredictable manner and seems quite specific to this project. The project has quite a few dependencies that are internal packages, so that doesn't help. The Vite error is not very useful as it is not mentioning what dependency it relates to, only that some cached chunk is missing.
I'm just wondering what could explain the mechanism that any change to the |
In case this data point helps, I just came across this error for the first time today in just a vite-built React app (nothing to do with Storybook), after invoking
After deleting the contents of that directory and re-running vite build, it's happy again. I searched, very little info out there on this error condition. |
In the case of Storybook with the Vite builder the deps are cache in the |
The same issue started happening to me today!
The issues seem to happen only in the dev branch, but it doesn't contain any changes to the SB or Vite configs 🤯 Storybook Environment Info:
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M1 Pro
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
Yarn: 4.3.1 - ~/.nvm/versions/node/v20.9.0/bin/yarn <----- active
npm: 10.8.1 - ~/.nvm/versions/node/v20.9.0/bin/npm
Browsers:
Chrome: 126.0.6478.183
Safari: 17.5
npmPackages:
@storybook/addon-essentials: 8.1.4 => 8.1.4
@storybook/addon-interactions: 8.1.4 => 8.1.4
@storybook/addon-links: 8.1.4 => 8.1.4
@storybook/addon-onboarding: 8.1.4 => 8.1.4
@storybook/addon-themes: 8.1.4 => 8.1.4
@storybook/blocks: 8.1.4 => 8.1.4
@storybook/manager-api: 8.1.4 => 8.1.4
@storybook/react: 8.1.4 => 8.1.4
@storybook/react-vite: 8.1.4 => 8.1.4
@storybook/test: 8.1.4 => 8.1.4
@storybook/test-runner: ^0.17.0 => 0.17.0
@storybook/theming: 8.1.4 => 8.1.4
chromatic: ^11.3.5 => 11.3.5
eslint-plugin-storybook: ^0.8.0 => 0.8.0
storybook: 8.1.4 => 8.1.4 "vite": "^5.2.11"
"@vitejs/plugin-react": "^4.2.1" UPD:Bumping to: "vite": "^5.3.4"
"@vitejs/plugin-react": "^4.3.1" helped to resurrect the Storybook, but I'm not sure about the longevity of such a solution... |
For me, deleting |
I'm not using storybook, but I'm getting the same message. I posted at vitejs/vite#17738 (not a bug report, because they require a minimal reproduction) |
I just had the same issue but with another project and without a dedicated frontend client like storybook here. For me disabling the cache on my browser and then reloading solved it. |
Another thing that helped - explicit storybook cache exclusion from the Vite's optimization: optimizeDeps: {
exclude: ['node_modules/.cache/storybook']
} UPD: After updating one of the dependencies in |
My error is:
And I add this to .storybook/main.ts:
This works for me |
I don't know if it'll help you or not but I was able to resolve the issue by deleting my local node_modules folder and then running 'npm install' fresh. In my case I believe the issue was caused by switching between branches that had different node_module configurations. I had run 'npm audit fix' on one branch then switched to another branch and then got this error. I didn't need to add any exclusions or anything else. |
As described in the issue, in this case deleting the |
Another thing that helps me with occasional cache mismatches is changing the: optimizeDeps: {
exclude: ['node_modules/.cache/storybook']
} to something absurd like: optimizeDeps: {
exclude: ['node_modules/.cache/storybook/fasfasfqwfqw']
} Then when I start the Storybook, it somehow revalidates the Vite's cache and runs all the stories properly. Then I can go back to the adequate path, restart, and enjoy my day till the next caching issue 🪄 |
@oleksandr-danylchenko yes that has been my mitigation too, see here: #28542 (comment) |
Thanks @timmevandermeer for your workaround. We already added |
Just ran into this issue today right after switching branches, installing dependencies, then switching back and re-installing. |
I've been having this issue intermittently in my local repo but never on CI. Clearing node_modules and/or the .cache directory specifically does nothing to resolve things. I noticed that switching browsers or going incognito results in no issues so I assume the issue is something browser cache related. I tried "clear site data" in chrome but it didn't work, but unchecking "disable cache" on the network tab, then reloading, then re-checking "disable cache" solved the issue in my original browser profile. |
Hi there! Thank you for opening this issue, but it has been marked as |
I'm afraid we need to close this issue for now, since we can't take any action without the requested reproduction or additional information. But please don't hesitate to open a new issue if the problem persists – we're always happy to help. Thanks so much for your understanding. |
Can this issue be reopened as a clear solution was not reached? |
Describe the bug
Often after switching branches I encounter the following error type when starting Storybook (causing it to fail to load)
Deleting the
.cache
folder or even the entirenode_modules
folder does not resolve this.However, there are a couple things that resolve it (until it occurs again):
main.ts
config (it seems any change will do)However, reverting the changes above causes the problem to re-emerge. The one thing I could think of here is that there is some caching (by Vite or Storybook) happening globally or at least outside the project folder, but I could not find any documentation on this
Reproduction link
Sorry I don't have any, it might be project specific
Reproduction steps
I don't have reproduction steps because it happens fairly randomly. It happens typically when switching between feature branches and then back.
System
Additional context
Storybook version: 8.1.11
Builder:
@storybook/react-vite
Project is monorepo with Yarn 4 workspaces
The text was updated successfully, but these errors were encountered: