-
Notifications
You must be signed in to change notification settings - Fork 106
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
build-storybook runs out of memory in Github Actions. #282
Comments
Vite is definitely fast in development (esbuild, no bundler), but when it builds for production, it uses rollup, which does a lot of work to bundle and treeshake, so it does take some time. That said, you shouldn't be running out of memory. You can try increasing the amount available to node with a top-level env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144 As for the sourcemap errors, I think the reason you don't see the output/errors is that chromatic builds storybook with a I've opened joshwooding/vite-plugin-react-docgen-typescript#1 to explore adding sourcemap support to that plugin. |
@IanVS Thanks for the quick answer again :) Adding the --max-old-space-size to the action did get my chromatic GitHub action passing now. 🎉 Although I do wonder if it's really supposed to be using that much more memory with vite than with webpack? Sadly I seem to also have run into more problems and inconsistencies with the production built storybook vs the dev storybook. But that's unrelated to this memory issue. Thanks again for the help! and for opening that ticket in the react-docgen plugin. |
I'd love to hear more about this, if you don't mind opening another issue or jumping into the #vite channel in the storybook discord. |
@IanVS let me have a crack at it first :) but yeah I'll join the discord or create a ticket if I can't solve it. |
@IanVS Yeah. The last few inconsistencies were due to environment variables not being picked up when building production vs building development. Now the only things left to "solve" are why my vite storybook is so slow, and the source maps you already created another issue for. It's not just the production build that's slow for me. But the development build can sometimes take over a minute to start up as well. (on my M1 max) I'm not sure why yet. dev mode started faster with CRA. But that's likely something specific to my project I'd imagine. I have another smaller project where vitejs storybook starts much faster than the CRA version. |
That's definitely strange. Vite can take some time to load in the browser in dev mode, but the dev server should start within a few seconds. My own storybook has 115 story files and nearly 500 stories, and it starts up in 10 seconds on my intel mac. Feel free to hop into the discord if you want to chat more about it. |
It seems like maybe this is a known vite issue: vitejs/vite#2433 |
Just wanted to bump this thread to note that I'm experiencing this issue too. I can run
I'm using:
|
@alextompkins are you able to give node a bit extra memory? Github runners have 7gb or so available, it's normally safe to increase the |
@IanVS yup that did the trick. Still seems odd that vite would need >1.4GB but 🤷 |
Yeah, I've spent some time trying to understand what's going on and why it is using so much, without any luck so far. |
Have found myself at the bottom of this thread after cranking up max_old_space_size on a github runner to 64gig with no luck although the error is now "Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory" instead of "Reached heap limit Allocation failed - JavaScript heap out of memory" which happened at 32gig. Our storybook contains 36 components if that gives a sense of scale. We can build locally so may just do that every-so-often but would be nice to automate this :-) It would be great if you have any suggestions! |
Having the same problem as above after moving from webpack to vite. The I've done some investigating and found that if I set |
It's possible that your github runners themselves do not have sufficient RAM. You may need more powerful boxes. The reason it happens with vite and not webpack is due to vite using rollup to build. This is the vite issue: vitejs/vite#2433. |
After switching from CRA / webpack@5, to vitejs and
storybook-builder-vite
I noticed my storybook takes a lot longer than usual to build. (I was expecting the opposite.)It's not the end of the world of course, but a bigger problem / sideeffect of this is that my Github action that builds storybook and publishes to Chromatic fails with a
JavaScript heap out of memory
error.My storybook build on my local machine (M1 Max) takes 60.05s, here is the log for that:
with CRA / webpack@5 it took 49.49s to build and did not have source map errors 🤔 (maybe that's the culprit)
Here is the output of the same project but with webpack@5 build-storybook
But the main problem is that when I try to build my storybook in a Github action, it runs out of memory, which means I can't use chromatic at all.
This is what my Github action looks like:
and here is the output of running the action:
I tried both with and without https://github.com/IanVS/vite-plugin-turbosnap
The text was updated successfully, but these errors were encountered: