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

Next 14 Build Performance on Windows (outputFileTracing) #60754

Open
1 task done
TheThirdRace opened this issue Jan 17, 2024 · 6 comments
Open
1 task done

Next 14 Build Performance on Windows (outputFileTracing) #60754

TheThirdRace opened this issue Jan 17, 2024 · 6 comments
Labels
bug Issue was opened via the bug report template. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

Comments

@TheThirdRace
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/hungry-bassi-hzgrzf?file=%2Fpages%2Findex.tsx

To Reproduce

outputFileTracing: false

  1. Set outputFileTracing: false in next.config.js
  2. Build the app
  3. Total time for my app build is 15 seconds
  4. Build again without any change so cache kicks in
  5. Total time for my app build is 6.5 seconds

outputFileTracing: true

  1. Set outputFileTracing: true in next.config.js
  2. Build the app
  3. Total time for my app build is 35 seconds
  4. Build again without any change so cache kicks in
  5. Total time for my app build is 15 seconds

Current vs. Expected behavior

Currently, it's possible to use outputFileTracing: false in your next.config.js.

Unfortunately, this option is gonna be removed in Next 15.x, as mentioned when running the build command:
image

This is unacceptable. This option is essential to build fast on Windows, with or without WSL2. I've been running for 2 years with the option disabled without any problem, there is no reason to remove it.

An alternative solution would be to not output at all the file tracing for anyone. Given I spent 2 years without it, I guess it's not an essential part of the build process...

This workaround exists for more than 2 years now. The only reasons I'm opening a new issue is because NextJs is declaring they're gonna remove the workaround soon...

Actually, here's the original issue from 2 years ago and it's still opened: #31021

Please, either fix the issue on Windows or do not deprecate the option. There is no need for a code sandbox here, it's an OS issue.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: 1.22.21
  pnpm: N/A
Relevant Packages:
  next: 14.0.4
  eslint-config-next: 14.0.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Operating System (Windows, MacOS, Linux)

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

Please see the original issue #31021

The issue has been open since the launch of NextJs 12.x, 2 years ago...

@TheThirdRace TheThirdRace added the bug Issue was opened via the bug report template. label Jan 17, 2024
@quentinjeanningros
Copy link

@TheThirdRace I just opened an issue yesterday, about compilation time in wsl2, do it look related to your ? #61340

@TheThirdRace
Copy link
Author

@TheThirdRace I just opened an issue yesterday, about compilation time in wsl2, do it look related to your ? #61340

It's not related no.

Your issue is about running the code (run dev) while mine is about building the code (run build).

@balazsorban44 balazsorban44 added Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). and removed area: OS labels Apr 17, 2024
@TheThirdRace
Copy link
Author

@timneutkens @balazsorban44
Could we get a look at this please 🙏

This issue has plagued people since Nov 5, 2021 (#31021).

We had a workaround in NextJs 14 with outputFileTracing: false, but now it's been removed in NextJs 15.

The issue on this page was my attempt to warn NextJs about the impending removal and the issues it would cause for some setup. Unfortunately, it has not been prioritized. The irony here is that the removal of the workaround was prioritized without having a solution first... Had no work been done at all about it, we'd all by happy 😥

My builds are now taking much longer since I've upgraded to NextJs 15. The numbers here are still relevant 2 years later:

@TheThirdRace
Copy link
Author

The deploy of my branch, with the upgrade to NextJs 15, failed.

Apparently, not only the build now is 2x as long, but somehow 2 serverless functions are busting the size limit 🤔

Looking at the logs (will share at the end), I can see a few weird things:

  1. Some elements should not be part of the build, don't know why they're included:
    • For some reason, git files seem to be included in the bundle
      • [16:45:16.307] .git/objects/pack 151.67 MB
    • The original images are kept in a folder as "documentation", I don't reference them anywhere in the code but they're somehow included in the bundle
      • [16:45:16.307] src/private/img 144.25 MB
    • All public/ folder images are bundled in the serverless function, even though only a few are actually used in the page. I always use a direct path for import, so there's no barrel file anywhere
      • [16:45:16.307] public/img/mass-effect-andromeda 36.43 MB
      • [16:45:16.308] node_modules/next/dist 8.13 MB
      • [16:45:16.308] public/img/site 7.4 MB
      • [16:45:16.308] public/img/dark-souls-3 5.77 MB
      • [16:45:16.308] public/img/skyrim 4.51 MB

Here's the complete log:

[16:42:50.910] Running build in Washington, D.C., USA (East) – iad1
[16:42:51.085] Cloning github.com/TheThirdRace/thethirdrace.com (Branch: chore/update-nextjs-15-1-3, Commit: a71c155)
[16:42:51.703] Previous build caches not available
[16:42:56.008] Cloning completed: 4.927s
[16:42:56.537] Running "vercel build"
[16:42:56.952] Vercel CLI 39.2.0
[16:42:57.563] Installing dependencies...
[16:42:57.903] yarn install v1.22.19
[16:42:57.982] [1/5] Validating package.json...
[16:42:57.985] [2/5] Resolving packages...
[16:42:58.366] [3/5] Fetching packages...
[16:43:28.638] [4/5] Linking dependencies...
[16:43:28.657] warning " > @chakra-ui/theme-tools@2.1.2" has unmet peer dependency "@chakra-ui/styled-system@>=2.0.0".
[16:43:41.501] [5/5] Building fresh packages...
[16:43:41.696] Done in 43.80s.
[16:43:41.736] Detected Next.js version: 15.1.3
[16:43:41.738] Running "yarn run build"
[16:43:41.925] yarn run v1.22.19
[16:43:41.948] $ node ./script/generateSitemap.mjs
[16:43:42.066] �[35mevent�[0m - Generating sitemap
[16:43:42.085]     �[32m/�[0m
[16:43:42.086]     �[32m/404�[0m
[16:43:42.086]     �[32m/500�[0m
[16:43:42.086]     �[32m/blog�[0m
[16:43:42.086]     �[32m/blog/2020-05-08-initial�[0m
[16:43:42.087]     �[32m/blog/2020-06-30-after-a-month�[0m
[16:43:42.087]     �[32m/blog/2021-01-22-typography�[0m
[16:43:42.087]     �[32m/contribute�[0m
[16:43:42.087]     �[32m/games/mass-effect-andromeda/multiplayer-build-list�[0m
[16:43:42.087]     �[32m/games/mass-effect-andromeda/multiplayer-character-builder�[0m
[16:43:42.087]     �[32m/games/mass-effect-andromeda/single-player-mod-list�[0m
[16:43:42.088]     �[32m/games/skyrim/master-trader�[0m
[16:43:42.088]     �[32m/games/skyrim/master-trader-se�[0m
[16:43:42.088]     �[32m/games/skyrim/oghma-infinium�[0m
[16:43:42.088]     �[32m/games/skyrim/ttrso�[0m
[16:43:42.088]     �[32m/games/skyrim/ziil-los-dii-du�[0m
[16:43:42.088]     �[32m/legal�[0m
[16:43:42.089]     �[32m/news�[0m
[16:43:42.089]     �[32m/news/2�[0m
[16:43:42.089]     �[32m/news/3�[0m
[16:43:42.089]     �[32m/news/4�[0m
[16:43:42.089]     �[32m/news/5�[0m
[16:43:42.089]     �[32m/news/6�[0m
[16:43:42.089]     �[32m/news/7�[0m
[16:43:42.089]     �[32m/news/8�[0m
[16:43:42.089]     �[32m/news/9�[0m
[16:43:42.096] $ next build
[16:43:42.878] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[16:43:42.879] This information is used to shape Next.js' roadmap and prioritize features.
[16:43:42.879] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[16:43:42.879] https://nextjs.org/telemetry
[16:43:42.879] 
[16:43:42.957]    ▲ Next.js 15.1.3
[16:43:42.958] 
[16:43:43.009]    Skipping validation of types
[16:43:43.010]    Skipping linting
[16:43:43.401]    Creating an optimized production build ...
[16:44:47.177]  ✓ Compiled successfully
[16:44:47.182]    Collecting page data ...
[16:44:51.790]    Generating static pages (0/27) ...
[16:44:55.185]    Generating static pages (6/27) 
[16:44:56.511]    Generating static pages (13/27) 
[16:44:57.543]    Generating static pages (20/27) 
[16:44:57.544]  ✓ Generating static pages (27/27)
[16:45:08.569]    Finalizing page optimization ...
[16:45:08.569]    Collecting build traces ...
[16:45:12.784] 
[16:45:12.796] Route (pages)                                                                                                  Size     First Load JS
[16:45:12.796] ┌ ○ / (2854 ms)                                                                                                1.31 kB         228 kB
[16:45:12.796] ├   /_app                                                                                                      0 B             226 kB
[16:45:12.797] ├ ○ /404 (2859 ms)                                                                                             1.1 kB          238 kB
[16:45:12.797] ├ ● /500 (2859 ms)                                                                                             1.12 kB         238 kB
[16:45:12.797] ├ ○ /anniversary/[[...anniversary]] (2853 ms)                                                                  8.67 kB         243 kB
[16:45:12.797] ├ ƒ /api/error                                                                                                 0 B             226 kB
[16:45:12.797] ├ ƒ /api/import                                                                                                0 B             226 kB
[16:45:12.797] ├ ƒ /api/payment/[[...payment]]                                                                                0 B             226 kB
[16:45:12.797] ├ ƒ /api/urls/[[...short-url]]                                                                                 0 B             226 kB
[16:45:12.798] ├ ● /blog/[[...blog]] (6793 ms)                                                                                2.25 kB         239 kB
[16:45:12.798] ├   ├ /blog (2859 ms)
[16:45:12.798] ├   ├ /blog/2020-05-08-initial (1312 ms)
[16:45:12.798] ├   ├ /blog/2020-06-30-after-a-month (1311 ms)
[16:45:12.798] ├   └ /blog/2021-01-22-typography (1311 ms)
[16:45:12.798] ├ ● /contribute/[[...contribute]] (1310 ms)                                                                    8.91 kB         259 kB
[16:45:12.798] ├   └ /contribute (1310 ms)
[16:45:12.798] ├ ○ /games/mass-effect-andromeda/multiplayer-build-list/[[...multiplayer-build-list]] (2854 ms)                20 kB           254 kB
[16:45:12.798] ├ ○ /games/mass-effect-andromeda/multiplayer-character-builder/[[...multiplayer-character-builder]] (2849 ms)  18.4 kB         258 kB
[16:45:12.798] ├ ○ /games/mass-effect-andromeda/single-player-mod-list/[[...single-player-mod-list]] (2855 ms)                6.62 kB         244 kB
[16:45:12.798] ├ ● /games/skyrim/master-trader-se/[[...master-trader-se]] (1307 ms)                                           993 B           238 kB
[16:45:12.798] ├   └ /games/skyrim/master-trader-se (1307 ms)
[16:45:12.798] ├ ● /games/skyrim/master-trader/[[...master-trader]] (1306 ms)                                                 955 B           238 kB
[16:45:12.798] ├   └ /games/skyrim/master-trader (1306 ms)
[16:45:12.798] ├ ● /games/skyrim/oghma-infinium/[[...oghma-infinium]] (1306 ms)                                               952 B           238 kB
[16:45:12.798] ├   └ /games/skyrim/oghma-infinium (1306 ms)
[16:45:12.798] ├ ● /games/skyrim/ttrso/[[...ttrso]] (1305 ms)                                                                 1 kB            238 kB
[16:45:12.798] ├   └ /games/skyrim/ttrso (1305 ms)
[16:45:12.798] ├ ● /games/skyrim/ziil-los-dii-du/[[...ziil-los-dii-du]] (729 ms)                                              950 B           238 kB
[16:45:12.798] ├   └ /games/skyrim/ziil-los-dii-du (729 ms)
[16:45:12.798] ├ ● /legal/[[...legal]] (729 ms)                                                                               1.38 kB         238 kB
[16:45:12.798] ├   └ /legal (729 ms)
[16:45:12.798] └ ● /news/[[...news]] (4989 ms)                                                                                2.15 kB         239 kB
[16:45:12.798]     ├ /news (728 ms)
[16:45:12.798]     ├ /news/3 (728 ms)
[16:45:12.798]     ├ /news/4 (728 ms)
[16:45:12.798]     ├ /news/2 (727 ms)
[16:45:12.798]     ├ /news/5 (727 ms)
[16:45:12.798]     ├ /news/6 (727 ms)
[16:45:12.798]     ├ /news/7
[16:45:12.799]     └ [+2 more paths]
[16:45:12.799] + First Load JS shared by all                                                                                  226 kB
[16:45:12.799]   ├ chunks/framework-19baaf6675f9027b.js                                                                       44.8 kB
[16:45:12.799]   ├ chunks/main-a0c8126736e23788.js                                                                            38.1 kB
[16:45:12.799]   ├ chunks/pages/_app-bdacf1bfa4e14c11.js                                                                      140 kB
[16:45:12.799]   └ other shared chunks (total)                                                                                3.27 kB
[16:45:12.799] 
[16:45:12.799] ƒ Middleware                                                                                                   49.1 kB
[16:45:12.799] 
[16:45:12.799] ○  (Static)   prerendered as static content
[16:45:12.799] ●  (SSG)      prerendered as static HTML (uses getStaticProps)
[16:45:12.799] ƒ  (Dynamic)  server-rendered on demand
[16:45:12.802] 
[16:45:12.924] Done in 91.00s.
[16:45:13.134] Traced Next.js server files in: 145.984ms
[16:45:16.299] Warning: Max serverless function size of 250 MB uncompressed reached
[16:45:16.300] Serverless Function's page: blog/[[...blog]].js
[16:45:16.307] Large Dependencies                Uncompressed size
[16:45:16.307] .git/objects/pack                         151.67 MB
[16:45:16.307] src/private/img                           144.25 MB
[16:45:16.307] public/img/mass-effect-andromeda           36.43 MB
[16:45:16.308] node_modules/next/dist                      8.13 MB
[16:45:16.308] public/img/site                              7.4 MB
[16:45:16.308] public/img/dark-souls-3                     5.77 MB
[16:45:16.308] public/img/skyrim                           4.51 MB
[16:45:16.308] src/pages/games                             2.39 MB
[16:45:16.308] node_modules/react-dom/cjs                  1.64 MB
[16:45:16.309] .next/trace                                 1.62 MB
[16:45:16.309] public/favicon/archive                      1.04 MB
[16:45:16.309] node_modules/framer-motion/dist           912.12 KB
[16:45:16.309] 
[16:45:16.309] All dependencies                          372.06 MB
[16:45:16.311] Serverless Function's page: news/[[...news]].js
[16:45:16.315] Large Dependencies                Uncompressed size
[16:45:16.315] .git/objects/pack                         151.67 MB
[16:45:16.315] src/private/img                           144.25 MB
[16:45:16.315] public/img/mass-effect-andromeda           36.43 MB
[16:45:16.316] node_modules/next/dist                      8.13 MB
[16:45:16.316] public/img/site                              7.4 MB
[16:45:16.316] public/img/dark-souls-3                     5.77 MB
[16:45:16.316] public/img/skyrim                           4.51 MB
[16:45:16.316] src/pages/games                             2.39 MB
[16:45:16.317] node_modules/react-dom/cjs                  1.64 MB
[16:45:16.317] .next/trace                                 1.62 MB
[16:45:16.317] public/favicon/archive                      1.04 MB
[16:45:16.317] node_modules/framer-motion/dist           912.12 KB
[16:45:16.317] 
[16:45:16.317] All dependencies                          372.06 MB
[16:45:16.319] Max serverless function size was exceeded for 2 functions
[16:45:16.325] Created all serverless functions in: 3.191s
[16:45:16.523] Collected static files (public/, static/, .next/static): 80.061ms
[16:45:16.732] Build Completed in /vercel/output [2m]
[16:45:17.181] Deploying outputs...
[16:45:35.142] Failed to process build result for "_next/data/F4ZmMRSZHT9oMSGyCEqTN/blog.json". Data: {"type":"Prerender"}.
[16:45:35.143] Failed to process build result for "_next/data/F4ZmMRSZHT9oMSGyCEqTN/blog/2020-05-08-initial.json". Data: {"type":"Prerender"}.
[16:45:35.143] Failed to process build result for "_next/data/F4ZmMRSZHT9oMSGyCEqTN/blog/2020-06-30-after-a-month.json". Data: {"type":"Prerender"}.
[16:45:35.144] Failed to process build result for "blog". Data: {"type":"Prerender"}.
[16:45:35.144] Failed to process build result for "blog/2020-05-08-initial". Data: {"type":"Prerender"}.
[16:45:35.144] Failed to process build result for "blog/2020-06-30-after-a-month". Data: {"type":"Prerender"}.
[16:45:35.144] Failed to process build result for "_next/data/F4ZmMRSZHT9oMSGyCEqTN/blog/2021-01-22-typography.json". Data: {"type":"Prerender"}.
[16:45:35.144] Failed to process build result for "blog/2021-01-22-typography". Data: {"type":"Prerender"}.
[16:45:35.144] Failed to process build result for "_next/data/F4ZmMRSZHT9oMSGyCEqTN/blog/[[...blog]].json". Data: {"type":"Prerender"}.
[16:45:35.145] Failed to process build result for "blog/[[...blog]]". Data: {"type":"Prerender"}.
[16:45:35.149] Error: The Serverless Function "_next/data/F4ZmMRSZHT9oMSGyCEqTN/blog.json" is 355.77mb which exceeds the maximum size limit of 300mb. Learn More: https://vercel.link/serverless-function-size
[16:45:37.574] 

@TheThirdRace
Copy link
Author

TheThirdRace commented Dec 28, 2024

I found the problem for the deployment on Vercel issue: #60754 (comment) (just took me 15 hours 🙄)

Because NextJs 15 removed outputFileTracing, the deployment was including files that should not have been included. No amount of outputFileTracingExcludes could remove these...

The problem in my case was that getStaticProps was using imports from another local file, amongst those imports were images from the public/ folder.

This seemed to trigger an edge case bug in the automatic output file tracing, which included things like all the images in the project and some files from the .git/ folder.

  • @timneutkens @balazsorban44 You might want to take a look at that to avoid the problem for those unfortunate enough to hit that problem

I can't explain exactly why it causes this, but as soon as I moved the local file imports inside the actual page that used these, the serverless outputs (ISR functions deployed on Vercel) went back to 4MB per page (compared to 300 MB to 1 GB with the bug).

Thus, you want what's used in getStaticProps to be coming from the page file itself or an external dependency, not from another local file.

@TheThirdRace
Copy link
Author

TheThirdRace commented Dec 29, 2024

🚨 This is still unresolved

While I could fix the deployment issue, the issue reported on this page (build times) is still well alive unfortunately.

The build time is still twice as long as when outputFileTrace is disabled (NextJs 14, it's always disabled in Next 15). That's a 100% slowdown, which is not negligeable....

The only way to get back the quicker builds would be to either:

  • re-introduce the outputFileTracing option so we can disable it
  • fix the performance issues in the file tracing itself

I can add any NextJs person to my private repository so they can clone it and debug the problem. It's very simple to contact me through this issue and I'll be quick to give access.

@TheThirdRace TheThirdRace reopened this Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

No branches or pull requests

3 participants