Skip to content

Turbopack and Tailwind hangs on large codebases #78407

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

Closed
hrhthegreat opened this issue Apr 22, 2025 · 1 comment · Fixed by #78462
Closed

Turbopack and Tailwind hangs on large codebases #78407

hrhthegreat opened this issue Apr 22, 2025 · 1 comment · Fixed by #78462
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@hrhthegreat
Copy link

hrhthegreat commented Apr 22, 2025

Link to the code that reproduces this issue

https://github.com/hamidrezahanafi/turbopack-tw-large-codebase

To Reproduce

  1. Start the dev mode with turbopack on
  2. App hangs on Compiling

Current vs. Expected behavior

Current: Application hangs on compiling
Expected: It should compile and show the page

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: 4.9.1
  pnpm: N/A
Relevant Packages:
  next: 15.3.0
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

Turbopack

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

next dev (local)

Additional context

This is related to tailwind/postcss plugin based on my investigation and I created this 40000 files codebase and it seems like this code on tailwind postcss plugin is registering all the files and it hangs when it pass certain number or size of files

@timneutkens
Copy link
Member

Hey @hrhthegreat, thanks for the great report with reproduction, huge help!
We've investigated and fixed the root cause of the hanging in this PR:

And while looking at this found that even with it not hanging it was taking quite long to process (unexpectedly long). We've made an improvement to that here:

It's still a bit slower than webpack on the amount of files Tailwind reports, we're going to investigate that further and fix it, but wanted to give you an update.
Thanks again!

timneutkens added a commit that referenced this issue Apr 27, 2025
## Improve IPC socket handling in Turbopack Node.js communication

### What?
Enhances the IPC communication between Turbopack and Node.js processes
by implementing proper socket backpressure handling.

### Why?
The current implementation doesn't properly handle backpressure when
writing to sockets, which can lead to hanging where Node.js doesn't
write the rest of the data.

### How?
- Added a `Writable` stream wrapper around the socket to properly handle
backpressure
- Implemented drain event handling to ensure data is written correctly
- Enabled noDelay on both the Node.js client and Rust server sides
- Moved stringify into the promise to make the stringify + write happen
in the same tick.

Part of PACK-4409

Fixes #78407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants