Workaround for [LazyCompilationBackend] Error: read ECONNRESET when using Webpack 5 lazy compilation #34795
Replies: 1 comment
-
|
Good workaround — confirmed correct. Here's the explanation of why it works in case it helps others. Why
Why With Additional tuning if you still see instability You can further control which entries get lazy-compiled: lazyCompilation: {
entries: true,
imports: false,
test: /src\/.*\.stories\.[jt]sx?$/, // only lazy-compile story files
},This restricts lazy compilation to story entry points and compiles everything else eagerly, which can improve stability further at the cost of slightly slower initial startup. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The Problem
Using lazyCompilation in Storybook config (
.storybook/main.js)triggers too many concurrent network requests as Webpack tries to handle every dynamic import on-demand.
I think this becomes especially problematic in Storybook, because it handles hundreds of individual stories and complex dependency trees. It seems that this leads to a massive spike in connections that overwhelms the backend. In my case, this "request flood" appeared to be the root cause of the connection reset (
ECONNRESET).The Workaround
The solution is to reduce the granularity of the lazy compilation by focusing on entries instead of imports.
In your
.storybook/main.js:Result
By switching to entries: true, the number of simultaneous connections is significantly reduced. In my environment, this stopped the crashes while maintaining the benefit of fast, on-demand builds.
Hope this helps anyone struggling with similar stability issues!
Beta Was this translation helpful? Give feedback.
All reactions