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

Optimizing dependencies in build mode fails with too many pending modules #13018

Closed
7 tasks done
randypuro opened this issue Apr 27, 2023 · 4 comments · Fixed by #15184
Closed
7 tasks done

Optimizing dependencies in build mode fails with too many pending modules #13018

randypuro opened this issue Apr 27, 2023 · 4 comments · Fixed by #15184
Labels
feat: deps optimizer Esbuild Dependencies Optimization p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@randypuro
Copy link

Describe the bug

The optimizedDepsBuildPlugin can result in a failed build if there are more than Rollup's maxParallelFileOps (default 20) awaiting optimization before the crawl has ended (which actually triggers the optimization). In the log lines below, note the 20 hanging module load operations.

In my case, increasing up the rollupOptions.maxParallelFileOps solved the issue.

Without understanding the details, I wonder if the issue is related to this recent pull request although I didn't use the feature before hand so can't say for certain.

Btw, I'm really bullish on this feature as it resolves a couple issues I was having seeing different behavior between dev and prod builds.

Reproduction

apologies

Steps to reproduce

Configure optimizeDeps.disabled to false and commonjsOptions.include to [] to enable the esbuild based dependency optimization.

Have a handful of top level external dependencies requiring optimization (eg commonjs), and reduce rollupOptions.maxParallelFileOps to a number less than the number of dependencies.

System Info

vite v4.33

Used Package Manager

yarn

Logs

error during build:
Error: Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/react.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/@emotion_react_jsx-runtime.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/bootstrap.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/@rails_ujs.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/polished.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/@emotion_react.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/rollbar.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/tippy__js.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/focus-trap.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/qs.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/@emotion_styled.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/react-map-gl.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/choices__js.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/@rails_activestorage.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/focus-trap-react.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/react-dom.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/axios.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/react_ujs.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/react-dom_client.js"
(vite:optimized-deps-build) load "/zygote/node_modules/.vite/deps_build-d123dee8/@rollbar_react.js"
at EventEmitter.handleEmptyEventLoop (file:///zygote/node_modules/rollup/dist/es/shared/node-entry.js:24884:20)
at Object.onceWrapper (node:events:627:28)
at EventEmitter.emit (node:events:513:28)
at process. (file:///zygote/node_modules/rollup/dist/es/shared/node-entry.js:24878:55)
at process.emit (node:events:525:35)

pid 1776 exit 1
Build with Vite failed! ❌

Validations

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) feat: deps optimizer Esbuild Dependencies Optimization and removed pending triage labels May 1, 2023
@bluwy
Copy link
Member

bluwy commented May 1, 2023

I can confirm in a large project too that #12851 (released in vite 4.3.0-beta.6) seems to make the rollupOptions.maxParallelFileOps workaround necessary. (Though the build hangs indefinitely for me without additional logs)

@sun0day
Copy link
Member

sun0day commented May 4, 2023

I can confirm in a large project too that #12851 (released in vite 4.3.0-beta.6) seems to make the rollupOptions.maxParallelFileOps workaround necessary. (Though the build hangs indefinitely for me without additional logs)

Can you provide a mini-repro, I can't reproduce it 😢

squaresmile added a commit to atlasacademy/apps that referenced this issue Aug 3, 2023
Increased maxParallelFileOps due to a problem with vite and rollup vitejs/vite#13018
@amalshaji
Copy link

I'm also facing the same issue. The project was on vite 4.2.2 when vite started producing different hashes and build sizes in consecutive builds. Based on this pr(#12558), vite was upgraded to 4.4.8. This was when we started getting the error. The current workaround is to set the rollupOptions.maxParallelFileOps to 100(arbitrary).

@matty-at-rdc
Copy link

This bit me today. Thanks for posting your solve @randypuro. @amalshaji I also arbitrarily set mine to 100 because im not even supposed to be in this area of my codebase 😂 🗺️

@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: deps optimizer Esbuild Dependencies Optimization p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
5 participants