Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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.js 10.0.3 gives Javascript heap out of memory error in dev environment with Tailwind CSS (PostCSS Plugin) #20445

Closed
ceodigvijay opened this issue Dec 24, 2020 · 9 comments
Labels
bug Issue was opened via the bug report template.

Comments

@ceodigvijay
Copy link

Describe the problem:
I am using TailwindCSS 2.0.2 with Next.js 10.0.3.
TailwindCSS plugin is causing very high memory requirement for Next.js (Node.js process eats all memory), sometimes it also throws Javascript heap out of memory error.

Hot reloading is slow (even if I manage it in some way) but the real pain is Next.js+tailwinds setup takes 3-4x memory compared to others (like I was using Bulma)
With Next.js+Bulma/Bootstrap setup = ~250mb
With Next.js+TailwindCSS as PostCSS plugin = ~800mb-1.5gb memory

Link to a minimal reproduction:
Clone this repo.
https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss

and run it in next.js dev environment and watch out your memory usage (generally it remains around 200-300MB but with Tailwinds 1.2GB).

I tried to debug it and as soon as I disable tailwinds plugin in PostCSS everything again goes normal.

The real problem seems to be in tailwinds PostCSS Plugin, is there any way to reduce memory usage or fix this issue?

PS: The real problem is I don't want to trigger Out of memory error on the server during the build time.
I am using UBUNTU 20.04 on the local system (just to know this is not a problem related to OS).

@ceodigvijay ceodigvijay added the bug Issue was opened via the bug report template. label Dec 24, 2020
@joshxyzhimself
Copy link

I've personally experienced this whenever I'm updating my tailwind config frequently on my project that is simply webpack + react, my solution was of course to close that webpack --watch --mode=development process and manually restart it

@caenguidanos
Copy link

Same problem!

@joshxyzhimself
Copy link

Would also like to add that I am also using Ubuntu 20.04, could be relevant or not

@Xetera
Copy link

Xetera commented Dec 27, 2020

I'm getting this too even without the template. Everything is fine when you build the server for production but something with the dev server seems to be causing issues and even locking up chrome dev tools on the frontend. Although I'm still trying to figure out if that last bit is caused by something on my end.

@awareness481
Copy link
Contributor

This is a known issue tailwindlabs/tailwindcss#2820 (comment) , upgrading to 2.0.2 should help although it doesn't completely remove the performance issues.

@ceodigvijay
Copy link
Author

This is a known issue tailwindlabs/tailwindcss#2820 (comment) , upgrading to 2.0.2 should help although it doesn't completely remove the performance issues.

I tried different versions including (0.x, 1.x and 2.x) but the issue persists. It may not be related to versions.

@awareness481
Copy link
Contributor

This is a known issue tailwindlabs/tailwindcss#2820 (comment) , upgrading to 2.0.2 should help although it doesn't completely remove the performance issues.

I tried different versions including (0.x, 1.x and 2.x) but the issue persists. It may not be related to versions.

Yes, the issue still persists but 2.0.2 has some important improvements. See tailwindlabs/tailwindcss#3032

@ceodigvijay
Copy link
Author

This is a known issue tailwindlabs/tailwindcss#2820 (comment) , upgrading to 2.0.2 should help although it doesn't completely remove the performance issues.

I tried different versions including (0.x, 1.x and 2.x) but the issue persists. It may not be related to versions.

Yes, the issue still persists but 2.0.2 has some important improvements. See tailwindlabs/tailwindcss#3032

Yes I did noticed 2.0.2 was slightly better then others with memory usage but still very bad, it needs much more improvements.

@joeinnes
Copy link

I ran into this issue and turned out my purge rules were not well written. I changed my purge block to:

  purge: {
    enabled: process.env.NODE_ENV === "production",
    content: [
      "./{components,pages}/**/*.{js,ts,jsx,tsx}"
    ],
  },

And now it builds fine.

@vercel vercel locked and limited conversation to collaborators Jan 19, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

7 participants