question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook running out of memory when building

See original GitHub issue

Describe the bug After upgrading from 6.0.12 to 6.0.21 when running npx http-server ./lib/storybook -p 8082 -a localhost at 69% built I get: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Note: in the past we have had the same problem on 5.x versions, which were resolved by upgrading node.

I appreciate this lacks a lot of context, and it’s a private repo so I’m unable to share as is, but if anyone is able to point me in the direction of diagnosing or potential causes, that would be of great help.

We are running typescript.

To Reproduce Steps to reproduce the behavior:

Run npx http-server ./lib/storybook -p 8082 -a localhost

Expected behavior Builds as expected

System: Please paste the results of npx sb@next info here.

System:
OS: Windows 10 10.0.19041
CPU: (8) x64 Intel® Core™ i7-8650U Binaries:
Node: 12.16.1 - C:\Program Files\nodejs npm: 6.13.4 - C:\Program Files\nodejs\n Browsers:
Chrome: 84.0.4147.135
Edge: Spartan (44.19041.423.0), Chromiu npmPackages:
@storybook/addon-actions: 6.0.21 => 6.0 @storybook/addon-essentials: 6.0.21 => @storybook/addon-knobs: 6.0.21 => 6.0.2 @storybook/addon-links: 6.0.21 => 6.0.2 @storybook/addon-toolbars: 6.0.21 => 6. @storybook/addons: 6.0.21 => 6.0.21
@storybook/react: 6.0.21 => 6.0.21
@storybook/theming: 6.0.21 => 6.0.21

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
gabrielliwerantcommented, Jan 26, 2021

This is an issue when using storybook in a monorepo (a repo containing many individual packages and their own node_modules folders). It seems that when using default configs, storybook runs out of memory because it is scanning all of the node_modules sub folders. If I remove all the node_modules folders, it works fine. Is there a recommended way to include storybook in a monorepo? I’m thinking I’ll have to use a custom webpack config that excludes the appropriate folders.

7reactions
gazpachucommented, Jun 7, 2021

Even with 6GB of RAM in docker, the build still fails:

INFO[0062] RUN npm install --unsafe-perm --legacy-peer-deps 
INFO[0062] cmd: /bin/sh                                 
INFO[0062] args: [-c npm install --unsafe-perm --legacy-peer-deps] 
INFO[0062] Pushing layer xxxx.ap-northeast-1.amazonaws.com/.../cache:xxxxxxxx to cache now 
INFO[0062] Running: [/bin/sh -c npm install --unsafe-perm --legacy-peer-deps] 
<--- Last few GCs --->
[113:0x589ab50]   107832 ms: Scavenge 2000.0 (2067.4) -> 1997.6 (2069.1) MB, 16.8 / 0.0 ms  (average mu = 0.723, current mu = 0.475) allocation failure 
[113:0x589ab50]   107936 ms: Scavenge 2001.6 (2069.1) -> 1999.8 (2072.6) MB, 12.5 / 0.1 ms  (average mu = 0.723, current mu = 0.475) allocation failure 
[113:0x589ab50]   108042 ms: Scavenge 2005.4 (2072.6) -> 2003.3 (2091.4) MB, 16.8 / 0.0 ms  (average mu = 0.723, current mu = 0.475) allocation failure 
<--- JS stacktrace --->
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
Segmentation fault (core dumped)
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 139
Cleaning up file based variables
00:00
ERROR: Job failed: command terminated with exit code 1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript heap out of memory when doing build-storybook
Describe the bug When trying to do build-storybook it gets to 92% and then fails with the following out of memory error: 92%...
Read more >
Storybook running out of memory when building #12348
This is an issue when using storybook in a monorepo (a repo containing many individual packages and their own node_modules folders). It seems...
Read more >
How to solve JavaScript heap out of memory error
To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. ... Alternatively, you ......
Read more >
Github Actions - Reached heap limit Allocation failed
Github Action gives my this error for the last "run: npm run build" FATAL ERROR ...
Read more >
CLI options - Storybook
Storybook is a frontend workshop for building UI components and pages in isolation ... configure/telemetry.md#how-to-opt-out) if you'd not like to share any ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found