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]: Javascript heap out of memory when doing build-storybook when using docgen: 'vue-component-meta' #26647

Closed
its-lee opened this issue Mar 26, 2024 · 9 comments · Fixed by #28589

Comments

@its-lee
Copy link

its-lee commented Mar 26, 2024

Describe the bug

Hi folks - Storybook is amazing and I ❤️ it - and I'm very happy that 'vue-component-meta' was added in Storybook 8.

I migrated my component library to Storybook 8 recently and although the development build (storybook dev -p 6006 --no-open) works without issue - the build (npx storybook build) fails locally and in CI due to running out of memory (see below).

Removing docgen: 'vue-component-meta' from the Storybook configuration resolves the issue - but this docgen is the main reason I've migrated across.

It fails while transforming the .ts & .vue files - so I'm wondering if it's doing something while bundling (which isn't necessary) that isn't happening when running in the dev build which would be fine to just have built instead.

The component library I'm building has ~75 Vue3 components and in Storybook 8 without vue-component-meta it would use ~1.7GB.

I've tried going up to as far with max_old_space_size as 16GB to even get it to build locally but to no avail. My CI provider allows up to 4GB so that would be the goal.

main.ts

import type { StorybookConfig } from '@storybook/vue3-vite';
import pkg from '../package.json';

// Don't include the '/' in the package name as otherwise storybook interprets as a hierarchy hint.
export const titlePrefix = `${pkg.name.split('/').at(-1)}@${pkg.version}`;

export default {
  stories: [
    {
      titlePrefix,
      directory: '../src/components/',
      files: '**/*.stories.@(js|jsx|ts|tsx)'
    }
  ],
  staticDirs: ['../public'],
  framework: { name: '@storybook/vue3-vite', options: { docgen: 'vue-component-meta' } },
  core: { builder: '@storybook/builder-vite' }
};

Trace just before crash:

> components@3.8.1 build-storybook
> npx --max_old_space_size=16384 storybook build

@storybook/cli v8.0.4

info => Cleaning outputDir: storybook-static
info => Loading presets
info => Building manager..
info => Manager built (88 ms)
info => Building preview..
info => Copying static files: public at storybook-static

[vite:dts] You are building a library that may not need to generate declaration files.

vite v4.4.9 building for production...

./sb-common-assets/fonts.css doesn't exist at build time, it will remain unchanged to be resolved at runtime
transforming (141) src/components/tabs/TabButtons/TabButtons.stories.ts

Trace after crash (running with --max_old_space_size=16384 to try to saturate my RAM):

> components@3.8.1 build-storybook
> npx --max_old_space_size=16384 storybook build

@storybook/cli v8.0.4

info => Cleaning outputDir: storybook-static
info => Loading presets
info => Building manager..
info => Manager built (96 ms)
info => Building preview..
info => Copying static files: public at storybook-static

[vite:dts] You are building a library that may not need to generate declaration files.

vite v4.4.9 building for production...

./sb-common-assets/fonts.css doesn't exist at build time, it will remain unchanged to be resolved at runtime
transforming (161) node_modules/@mdx-js/react/index.js
<--- Last few GCs --->

[64674:0x120040000]    72249 ms: Mark-sweep 4022.0 (4136.7) -> 4007.9 (4138.5) MB, 1221.8 / 0.0 ms  (average mu = 0.113, current mu = 0.007) allocation failure; scavenge might not succeed
[64674:0x120040000]    73475 ms: Mark-sweep 4023.7 (4138.5) -> 4009.8 (4140.5) MB, 1216.9 / 0.0 ms  (average mu = 0.063, current mu = 0.008) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10444a6e4 node::Abort() [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 2: 0x10444a8c8 node::ModifyCodeGenerationFromStrings(v8::Local<v8::Context>, v8::Local<v8::Value>, bool) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 3: 0x1045a160c v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 4: 0x10474bec4 v8::internal::EmbedderStackStateScope::EmbedderStackStateScope(v8::internal::Heap*, v8::internal::EmbedderStackStateScope::Origin, cppgc::EmbedderStackState) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 5: 0x10474fab0 v8::internal::Heap::CollectSharedGarbage(v8::internal::GarbageCollectionReason) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 6: 0x10474cac4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*, v8::GCCallbackFlags) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 7: 0x104749dc4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 8: 0x10473e900 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
 9: 0x10473f144 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
10: 0x1047250c4 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
11: 0x104ac56c0 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
12: 0x104e1504c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
13: 0x10b03916c 
14: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
15: 0x10b7538ec 
16: 0x10c72bbfc 
17: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
18: 0x10c2d4d54 
19: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
20: 0x10c2d4a14 
21: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
22: 0x10b753c10 
23: 0x10c72bbfc 
24: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
25: 0x10b0390d4 
26: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
27: 0x10b7538ec 
28: 0x10c72bbfc 
29: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
30: 0x10c2d4d54 
31: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
32: 0x10c2d4a14 
33: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
34: 0x10b753c10 
35: 0x10c72bbfc 
36: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
37: 0x10b0390d4 
38: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
39: 0x10b7538ec 
40: 0x10c72bbfc 
41: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
42: 0x10c2d4d54 
43: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
44: 0x10c2d4a14 
45: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
46: 0x10b753c10 
47: 0x10c72bbfc 
48: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
49: 0x10b0390d4 
50: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
51: 0x10b7538ec 
52: 0x10c72bbfc 
53: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
54: 0x10c2d4d54 
55: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
56: 0x10c2d4a14 
57: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
58: 0x10b753c10 
59: 0x10c72bbfc 
60: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
61: 0x10b0390d4 
62: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
63: 0x10b7538ec 
64: 0x10c72bbfc 
65: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
66: 0x10c2d4d54 
67: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
68: 0x10c2d4a14 
69: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
70: 0x10b753c10 
71: 0x10c72bbfc 
72: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
73: 0x10b0390d4 
74: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
75: 0x10b7538ec 
76: 0x10c72bbfc 
77: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
78: 0x10c2d4d54 
79: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
80: 0x10c2d4a14 
81: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
82: 0x10b753c10 
83: 0x10c72bbfc 
84: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
85: 0x10b0390d4 
86: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
87: 0x10b7538ec 
88: 0x10c72bbfc 
89: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
90: 0x10c2d4d54 
91: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
92: 0x10c2d4a14 
93: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
94: 0x10b753c10 
95: 0x10c72bbfc 
96: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
97: 0x10b0390d4 
98: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
99: 0x10b7538ec 
100: 0x10c72bbfc 
101: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
102: 0x10c2d4d54 
103: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
104: 0x10c2d4a14 
105: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
106: 0x10b753c10 
107: 0x10c72bbfc 
108: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
109: 0x10b0390d4 
110: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
111: 0x10b7538ec 
112: 0x10c72bbfc 
113: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
114: 0x10c2d4d54 
115: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
116: 0x10c2d4a14 
117: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
118: 0x10b753c10 
119: 0x10c72bbfc 
120: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
121: 0x10b0390d4 
122: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
123: 0x10b7538ec 
124: 0x10c72bbfc 
125: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
126: 0x10c2d4d54 
127: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
128: 0x10c2d4a14 
129: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
130: 0x10b753c10 
131: 0x10c72bbfc 
132: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
133: 0x10b0390d4 
134: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
135: 0x10b7538ec 
136: 0x10c72bbfc 
137: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
138: 0x10c2d4d54 
139: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
140: 0x10c2d4a14 
141: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
142: 0x10b753c10 
143: 0x10c72bbfc 
144: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
145: 0x10b0390d4 
146: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
147: 0x10b753c10 
148: 0x10c72bbfc 
149: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
150: 0x10bf52034 
151: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
152: 0x10b7538ec 
153: 0x10c72bbfc 
154: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
155: 0x10c2d4d54 
156: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
157: 0x10c2d4a14 
158: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
159: 0x10b753c10 
160: 0x10c72bbfc 
161: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
162: 0x10b0390d4 
163: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
164: 0x10b7538ec 
165: 0x10c72bbfc 
166: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
167: 0x10c2d4d54 
168: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
169: 0x10c2d4a14 
170: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
171: 0x10b753c10 
172: 0x10c72bbfc 
173: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
174: 0x10b0390d4 
175: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
176: 0x10b7538ec 
177: 0x10c72bbfc 
178: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
179: 0x10c2d4d54 
180: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
181: 0x10c2d4a14 
182: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
183: 0x10b753c10 
184: 0x10c72bbfc 
185: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
186: 0x10b0390d4 
187: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
188: 0x10b7538ec 
189: 0x10c72bbfc 
190: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
191: 0x10c2d4d54 
192: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
193: 0x10c2d4a14 
194: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
195: 0x10b753c10 
196: 0x10c72bbfc 
197: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
198: 0x10b0390d4 
199: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
200: 0x10b7538ec 
201: 0x10c72bbfc 
202: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
203: 0x10c2d4d54 
204: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
205: 0x10c2d4a14 
206: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
207: 0x10b753c10 
208: 0x10c72bbfc 
209: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
210: 0x10b0390d4 
211: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
212: 0x10b7538ec 
213: 0x10c72bbfc 
214: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
215: 0x10c2d4d54 
216: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
217: 0x10c2d4a14 
218: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
219: 0x10b753c10 
220: 0x10c72bbfc 
221: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
222: 0x10b0390d4 
223: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
224: 0x10b7538ec 
225: 0x10c72bbfc 
226: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
227: 0x10c2d4d54 
228: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
229: 0x10c2d4a14 
230: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
231: 0x10b753c10 
232: 0x10c72bbfc 
233: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
234: 0x10b0390d4 
235: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
236: 0x10b753c10 
237: 0x10c72bbfc 
238: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
239: 0x10bf52034 
240: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
241: 0x10b7538ec 
242: 0x10c72bbfc 
243: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
244: 0x10c2d4d54 
245: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
246: 0x10c2d4a14 
247: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
248: 0x10b753c10 
249: 0x10c72bbfc 
250: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
251: 0x10b0390d4 
252: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
253: 0x10b7538ec 
254: 0x10c72bbfc 
255: 0x104d9d700 construct_stub_create_deopt_addr [/Users/lee/.nvm/versions/node/v18.17.0/bin/node]
[1]    64627 abort      npm run build-storybook

To Reproduce

See bug description

System

Storybook Environment Info:

  System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm <----- active
    pnpm: 8.9.2 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 123.0.6312.59
    Safari: 17.2.1
  npmPackages:
    @storybook/addon-essentials: ^8.0.4 => 8.0.4 
    @storybook/addon-interactions: ^8.0.4 => 8.0.4 
    @storybook/addon-links: ^8.0.4 => 8.0.4 
    @storybook/blocks: ^8.0.4 => 8.0.4 
    @storybook/vue3: ^8.0.4 => 8.0.4 
    @storybook/vue3-vite: ^8.0.4 => 8.0.4 
    chromatic: ^11.0.0 => 11.0.0 
    storybook: ^8.0.4 => 8.0.4

Additional context

No response

@bauer00
Copy link

bauer00 commented Mar 27, 2024

I just encountered the same problem. I can build it locally, but not on CI, probably because the project is not as big yet.

I think it's related to using "html types" like HTMLElement. I have a component which uses HTMLElement and HTMLDivElement and the story additionally uses HTMLAnchorElement and this generates a 38mb big js file for the story.

image

Looking at the content, it seems like it pulls the MDN documentation into it for some reason:

image

I had to switch to vue-component-meta because I ran into this issue as I'm using exported props from another component: #24621
But of course, the autogenerated doc is also way better from what I've seen so far with vue-component-meta.

@drik98
Copy link
Contributor

drik98 commented Apr 11, 2024

We also just switched to vue-component-meta to resolve an issue with type inheritance. This came with a huge slowdown in performance. A build went from an easy <1 minute to almost 10 minutes.

@baixiaoyu2997
Copy link

this will cause error on vercel: At least one "Out of Memory" ("OOM") event was detected during the build.

@larsrickert
Copy link
Contributor

@its-lee Hey, do you perhaps have an example repository for us so we can check the performance issues?

@bauer00 Could you please share your CTooltip.vue file?

@its-lee
Copy link
Author

its-lee commented Apr 13, 2024

Hey @larsrickert the issue I'm getting this with is a private repo with 70 Vue + TS components, none of which being too complex (also each being < 200 lines of code).

It's a private repo so I'll try and generate something anonymised based on it, but hopefully the above is helpful.

@bauer00
Copy link

bauer00 commented Apr 13, 2024

@larsrickert I quickly created a more isolated test component I can share:

CTest.vue:

<script lang="ts" setup>
import { watch } from 'vue'
import { unrefElement, useEventListener, type VueInstance } from '@vueuse/core'

export interface CTestProps {
    triggerRef: HTMLElement | VueInstance | null
}

const props = defineProps<CTestProps>()

const onTriggerElementEnter = () => {
    console.log('onTriggerElementEnter')
}

const onTriggerElementLeave = () => {
    console.log('onTriggerElementLeave')
}

const unwatchTriggerRef = watch(
    () => props.triggerRef,
    () => {
        if (!props.triggerRef) {
            return
        }

        const triggerElement = unrefElement(props.triggerRef)

        useEventListener(triggerElement, ['mouseenter'], onTriggerElementEnter, { passive: true })
        useEventListener(triggerElement, ['mouseleave'], onTriggerElementLeave, { passive: true })

        unwatchTriggerRef()
    },
)
</script>

<template>
    <div class="test"><slot /></div>
</template>

CTest.stories.ts:

import { ref } from 'vue'
import { type Meta, type StoryObj } from '@storybook/vue3'
import CTest from './CTest.vue'

const meta: Meta<typeof CTest> = {
    title: 'Components/Test',
    component: CTest,
    argTypes: {
        default: {
            control: { type: 'text' },
        },
        triggerRef: {
            control: false,
        },
    },
    args: {
        default: 'Content',
    },
}
export default meta

type Story = StoryObj<typeof CTest>

export const Default: Story = {
    render: (args) => ({
        components: { CTest },
        setup() {
            const linkTriggerRef = ref<HTMLAnchorElement | null>(null)

            return { args, linkTriggerRef }
        },
        template: `
            <a href="#" ref="linkTriggerRef">Hover me</a>
            <CTest :trigger-ref="linkTriggerRef" v-bind="args">{{ args.default }}</CTest>
        `,
    }),
}

And this results in a 38mb big file when built:
image

@larsrickert
Copy link
Contributor

larsrickert commented Apr 14, 2024

@larsrickert I quickly created a more isolated test component I can share:

Thanks! The issue seems to be the HTMLElement...I can try to find a fix for this but I am not sure how much time this will take.

In the meantime, using Pick to only use the properties that are actually used by your component seems to fix the issue until we find a general fix for it. I am not sure if this works with the expected type from @vueuse/core.

Example:

export interface CTestProps {
    triggerRef: Pick<HTMLElement, "addEventListener" | "removeEventListener">| null
}

@bauer00
Copy link

bauer00 commented Apr 17, 2024

In the meantime, using Pick to only use the properties that are actually used by your component seems to fix the issue until we find a general fix for it. I am not sure if this works with the expected type from @vueuse/core.

That's good to know, thanks! I think for this particular case this doesn't work, as we want to generally limit the prop type to an HTMLElement or VueComponent, but it might come in handy in other cases. I guess all types "exposed" to storybook are affected by this problem, not just props.

The VueInstance type from @vueuse/core is indeed looking a bit strange, might have to check for alternatives, but for now it's ok.
image

@santerinogelainen
Copy link

I have the same issue with vue-component-meta. Our components use vue-ignore and HTMLAttributes to have intellisense on fallthrough attributes.

import type { HTMLAttributes } from 'vue'

export interface ComponentProps extends /* @vue-ignore */ HTMLAttributes {
   ...
}

This causes the build to create massive files with all the docs from the HTMLAttributes.

vue-component-meta seems to have an option to ignore types with schema: { ignore: ['MyIgnoredNestedProps'] }, (see README.md). I think it would be useful, if we could configure the ignored types in storybook docgen options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants