<p dir="auto">Subj,<br>
as example<br>
I create some module in another folder ( /projects/MY_MODULE )<br>
MY_MODULE not compiled, source code<br>
then run npm link<br>
after go to my project and run npm link MY_MODULE<br>
Compile my project and have error two copies React</p>
<p dir="auto">i`am try</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
        test: /\.js$/,
        exclude: [/node_modules/],
        include: [/node_modules\/MY_MODULE/]
      },"><pre class="notranslate"><code class="notranslate">{
        test: /\.js$/,
        exclude: [/node_modules/],
        include: [/node_modules\/MY_MODULE/]
      },
</code></pre></div>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sokra/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/sokra">@sokra</a></p>
<p dir="auto">I find a bug that cause Webpack hangs after build finished in latest version 5.32.1 because of <a href="https://github.com/webpack/webpack/pull/14174/files#diff-428c41964bad5dfd5424e7be2839c92ff9395632a7f29399eb21b37977f1ee5eR81">this line</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="991045929" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/14174" data-hovercard-type="pull_request" data-hovercard-url="/webpack/webpack/pull/14174/hovercard" href="https://github.com/webpack/webpack/pull/14174">#14174</a></p>
<p dir="auto">Webpack 5.52.1 prod build with cache:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="webpack 5.52.1 compiled with 8 warnings in 2010 ms
✨  Done in 61.31s."><pre class="notranslate"><code class="notranslate">webpack 5.52.1 compiled with 8 warnings in 2010 ms
✨  Done in 61.31s.
</code></pre></div>
<p dir="auto">Webpack 5.52.0 prod build with cache:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="webpack 5.52.0 compiled with 8 warnings in 1974 ms
✨  Done in 2.72s."><pre class="notranslate"><code class="notranslate">webpack 5.52.0 compiled with 8 warnings in 1974 ms
✨  Done in 2.72s.
</code></pre></div>
<p dir="auto">The root cause of this bug is <code class="notranslate">setTimeout(..., MAX_TIME_IN_FRESH_PACK)</code> keeps event loop not empty util 1mins passed.</p>
<blockquote>
<p dir="auto">For more details, in this question <a href="https://stackoverflow.com/questions/19699619/when-does-nodejs-process-quit" rel="nofollow">When does Nodejs process quit?</a> it said<br>
Node's mechanism is the event loop and a node process will generally exit when:</p>
<ol dir="auto">
<li>The event loop's queue is empty.</li>
<li>No background/asynchronous tasks remain that are capable of adding to the queue.</li>
</ol>
</blockquote>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">Since it is an obvious bug that I could find the root cause line of code. I didn't prepare a reproduce example. But I believe and Webpack 5.52.1 with cache enabled could reproduce this issue.</p>






<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">Webpack process should exit immediately after finished build.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.52.1<br>
Node.js version: 14.15.3<br>
Operating System: Darwin Malash-MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64 i386 MacBookPro16,1 Darwin<br>
Additional tools:</p>