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 fails to build on large Angular projects due to excessive Compodoc output #22400

Closed
michael-wisely-gravwell opened this issue May 4, 2023 · 3 comments · Fixed by #22441

Comments

@michael-wisely-gravwell
Copy link

Describe the bug

The start-storybook and build-storybook builders fail with exit code 127 on large Angular projects.

There is no output over stdout or stderr. There are no files produced. There is only a non-zero exit code.

This is what I see when I attempt to run the start-storybook builder:

$ ng run myproject:storybook
$ echo $?
127

Please see Additional Context for an explanation of what I believe is causing this failure as well as some possible solutions.

To Reproduce

No response

System

Environment Info:

  System:
    OS: Linux 6.2 Pop!_OS 22.04 LTS
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    npm: 9.6.3 - ~/.nvm/versions/node/v18.16.0/bin/npm
  Browsers:
    Chrome: 112.0.5615.165
    Firefox: 112.0.1
  npmPackages:
    @storybook/addon-actions: ^7.0.8 => 7.0.8 
    @storybook/addon-essentials: ^7.0.8 => 7.0.8 
    @storybook/addon-links: ^7.0.8 => 7.0.8 
    @storybook/angular: ^7.0.8 => 7.0.8

Additional context

The problem appears to be due to the fact that...

  1. Compodoc is VERY chatty
    • On my project, compodoc produces 1,347,625 bytes of output
  2. Storybook attempts to buffer the output from compodoc
  3. The default maxBuffer on spawnSync is 1024*1024 = 1,048,576 bytes
  4. Node will terminate child processes if output exceeds the maxBuffer

In my case, the 1,347,625 bytes of output exceeds the default maximum of 1,048,576 bytes, causing compodoc to be terminated.

I've done some investigating and found three bits of evidence that support this idea:

  1. If I suppress compodoc's output with...

    npx ng run myproject:storybook --compodoc-args='--silent --exportFormat=json'
    

    ... then storybook builds/starts just fine.

  2. If I modify JSPackageManager#executeCommand, so that it defaults to "inherit" instead of "pipe", then all of compodoc's output is shown on my console instead of being buffered. This allows me to build/start storybook successfully.

  3. If I modify JSPackageManager#executeCommand, so that its maxBuffer is arbitrarily huge (e.g. 3000000), then the output is buffered successfully and is output when the spawned compodoc finishes. Storybook then proceeds successfully.

Possible solutions:

  • For those encountering this problem today, passing --silent to --compodoc-args is a fine workaround.
  • As a more permanent solution, I think it may be a good idea to change runCompodoc to use inherit for stdio. Setting the maxBuffer arbitrarily high doesn't sound as sustainable, as some folks may require an even higher buffer.
@michael-wisely-gravwell michael-wisely-gravwell changed the title [Bug]: Storybook fails to build large on Angular projects due to excessive Compodoc output [Bug]: Storybook fails to build on large Angular projects due to excessive Compodoc output May 4, 2023
@valentinpalkovic valentinpalkovic self-assigned this May 7, 2023
@shilman
Copy link
Member

shilman commented May 11, 2023

Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.1.0-alpha.16 containing PR #22441 that references this issue. Upgrade today to the @future NPM tag to try it out!

npx sb@next upgrade --tag future

@shilman
Copy link
Member

shilman commented May 22, 2023

Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.13 containing PR #22441 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb@latest upgrade

@michael-wisely-gravwell
Copy link
Author

The fix works great! 🎉

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

Successfully merging a pull request may close this issue.

3 participants