nextjs - 💡(How to fix) Fix "Overly broad patterns" warnings during build [8 comments, 8 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85366Fetched 2026-04-08 02:16:11
View on GitHub
Comments
8
Participants
8
Timeline
21
Reactions
10
Author
Timeline (top)
commented ×8subscribed ×6labeled ×3closed ×1

Code Example

> turbopack-warning-repro@1.0.0 build
> next build

Next.js 16.0.0 (Turbopack)

   Creating an optimized production build ...
Turbopack build encountered 2 warnings:
./src/actions/files.ts:32:24
The file pattern ('/ROOT/public/' <dynamic> '/' <dynamic> | '/ROOT/public' <dynamic> '/' <dynamic> | '/ROOT/public/' <dynamic> | '/ROOT/public' <dynamic>) matches 16000 files in [project]/
  30 |
  31 |   // This also triggers the warning
> 32 |   const resolvedPath = path.resolve(
     |                        ^^^^^^^^^^^^^
> 33 |     baseDir,
     | ^^^^^^^^^^^^
> 34 |     userPath.replace(/^\//, ""),
     | ^^^^^^^^^^^^
> 35 |     fileName
     | ^^^^^^^^^^^^
> 36 |   );
     | ^^^^
  37 |
  38 |   return resolvedPath;
  39 | }

Overly broad patterns can lead to build performance issues and over bundling.

Import trace:
  Server Component:
    ./src/actions/files.ts
    ./src/app/page.tsx


./src/actions/files.ts:20:22
The file pattern ('/ROOT/public/media/' <dynamic> '/' <dynamic> | '/ROOT/public/media' <dynamic> '/' <dynamic> | '/ROOT/public/media/' <dynamic> | '/ROOT/public/media' <dynamic>) matches 32000 files in [project]/
  18 |   // This line triggers the warning:
  19 |   // "The file pattern matches X files... Overly broad patterns can lead to build performance issues"
> 20 |   const targetPath = path.join(mediaDir, folder, filename);
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  21 |
  22 |   return targetPath;
  23 | }

Overly broad patterns can lead to build performance issues and over bundling.

Import trace:
  Server Component:
    ./src/actions/files.ts
    ./src/app/page.tsx


Compiled successfully in 862.8ms
Finished TypeScript in 650.1ms    
Collecting page data in 162.0ms    
Generating static pages (3/3) in 214.6ms
Finalizing page optimization in 3.7ms    

Route (app)
┌ ○ /
└ ○ /_not-found


  (Static)  prerendered as static content

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun, 19 Oct 2025 19:21:18 +0000
  Available memory (MB): 61858
  Available CPU cores: 16
Binaries:
  Node: 22.20.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.0 // Latest available version is detected (16.0.0).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Hello,

after upgrading our application to next.js 16 we see lots of build warnings from turbopack for a server action which handles file uploads. This only seems to happen when a certain amount of files exists and path.join() or path.resolve() is used.

Is there a way to either fix these warnings, supress them or is it simply a case of not being best practices and files should be somewhere else?

Edit 2025-10-28: The problem remains with version 16.0.1.

Link to the code that reproduces this issue

https://github.com/MarcJose/nextjs16-turbopack

To Reproduce

The example project reproduces this warning by creating a certain amount of dummy files in the project as postinstall and having a server action to get the path of a file at runtime.

Current vs. Expected behavior

Current:


> [email protected] build
> next build

   ▲ Next.js 16.0.0 (Turbopack)

   Creating an optimized production build ...
Turbopack build encountered 2 warnings:
./src/actions/files.ts:32:24
The file pattern ('/ROOT/public/' <dynamic> '/' <dynamic> | '/ROOT/public' <dynamic> '/' <dynamic> | '/ROOT/public/' <dynamic> | '/ROOT/public' <dynamic>) matches 16000 files in [project]/
  30 |
  31 |   // This also triggers the warning
> 32 |   const resolvedPath = path.resolve(
     |                        ^^^^^^^^^^^^^
> 33 |     baseDir,
     | ^^^^^^^^^^^^
> 34 |     userPath.replace(/^\//, ""),
     | ^^^^^^^^^^^^
> 35 |     fileName
     | ^^^^^^^^^^^^
> 36 |   );
     | ^^^^
  37 |
  38 |   return resolvedPath;
  39 | }

Overly broad patterns can lead to build performance issues and over bundling.

Import trace:
  Server Component:
    ./src/actions/files.ts
    ./src/app/page.tsx


./src/actions/files.ts:20:22
The file pattern ('/ROOT/public/media/' <dynamic> '/' <dynamic> | '/ROOT/public/media' <dynamic> '/' <dynamic> | '/ROOT/public/media/' <dynamic> | '/ROOT/public/media' <dynamic>) matches 32000 files in [project]/
  18 |   // This line triggers the warning:
  19 |   // "The file pattern matches X files... Overly broad patterns can lead to build performance issues"
> 20 |   const targetPath = path.join(mediaDir, folder, filename);
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  21 |
  22 |   return targetPath;
  23 | }

Overly broad patterns can lead to build performance issues and over bundling.

Import trace:
  Server Component:
    ./src/actions/files.ts
    ./src/app/page.tsx


 ✓ Compiled successfully in 862.8ms
 ✓ Finished TypeScript in 650.1ms    
 ✓ Collecting page data in 162.0ms    
 ✓ Generating static pages (3/3) in 214.6ms
 ✓ Finalizing page optimization in 3.7ms    

Route (app)
┌ ○ /
└ ○ /_not-found


(Static)  prerendered as static content

Expected:

Clean build.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun, 19 Oct 2025 19:21:18 +0000
  Available memory (MB): 61858
  Available CPU cores: 16
Binaries:
  Node: 22.20.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.0 // Latest available version is detected (16.0.0).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.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 build (local)

Additional context

No response

extent analysis

TL;DR

The most likely fix for the Turbopack build warnings is to refactor the file paths to be more specific, reducing the number of matched files.

Guidance

  • Identify the file patterns causing the warnings and refactor them to be more specific, reducing the number of matched files.
  • Consider using a more efficient file system structure or organization to minimize the number of files in the affected directories.
  • Review the path.join() and path.resolve() usage in the code to ensure they are necessary and optimal for the application's requirements.
  • If the warnings persist, consider suppressing them using Turbopack configuration options, but be aware that this may lead to build performance issues or over-bundling.

Example

No specific code example is provided, as the issue is more related to file system structure and path usage. However, the example project linked in the issue can be used as a reference to reproduce and debug the problem.

Notes

The issue is specific to Turbopack and Next.js 16, and the provided environment information and code example can help in debugging and resolving the problem. The warnings are related to overly broad file patterns, which can lead to build performance issues and over-bundling.

Recommendation

Apply a workaround by refactoring the file paths to be more specific, as the issue persists even with the latest available version of Next.js (

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix "Overly broad patterns" warnings during build [8 comments, 8 participants]