<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
A 5 row NodeJS application, <a href="https://github.com/MorganLindqvist/webpack5-http-auth-failure">https://github.com/MorganLindqvist/webpack5-http-auth-failure</a>, works as it should without Webpack-5. But when running after webpack the application crashes.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
<code class="notranslate">git clone https://github.com/MorganLindqvist/webpack5-http-auth-failure.git</code><br>
<code class="notranslate">cd webpack5-http-auth-failure</code><br>
<code class="notranslate">npm install</code><br>
<code class="notranslate">npm run build_dev</code><br>
<code class="notranslate">node dist/main.js</code></p>
<p dir="auto">The 5-row application that crashes is as follows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const auth = require(&quot;http-auth&quot;);
const basic = auth.basic({
  realm: &quot;Realm&quot;,
  file: __dirname + &quot;/../htpasswd&quot;
});"><pre class="notranslate"><code class="notranslate">const auth = require("http-auth");
const basic = auth.basic({
  realm: "Realm",
  file: __dirname + "/../htpasswd"
});
</code></pre></div>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
This small snippit is a part of a larger NodeJS application and the same error/crash (see below) is triggered in that one when the usage of http-auth module was added. The error message I receive s as follows:</p>
<p dir="auto"><code class="notranslate">TypeError: Can not find node binding files from @node-rs/bcrypt-linux-x64-gnu, @node-rs/bcrypt-linux-x64-gnux32, @node-rs/bcrypt-linux-x64-musl and /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-gnu.node, /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-gnux32.node, /home/user/webpack5-http-auth-failure/dist/bcrypt.linux-x64-musl.node </code><br>
Until it is fixed, can I bypass it in some way?</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.30.0<br>
Node.js version: v14.16<br>
Operating System: Ubuntu 20.04<br>
Additional tools: npm: 6.14.11</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">Crashes with a stack trace of</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ npm run webpack:dev

&gt; @hyperledger/cactus@ webpack:dev *REDACTED_PATH*
&gt; node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js --display-error-details --env env-csv=dev --env target-csv=node

*REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:371
                                                        if (item) flattenedResult.push(...item);
                                                                                  ^

RangeError: Maximum call stack size exceeded
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:371:34
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)
    at *REDACTED_PATH*/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at done (*REDACTED_PATH*/node_modules/neo-async/async.js:2931:13)"><pre class="notranslate">$ npm run webpack:dev

<span class="pl-k">&gt;</span> @hyperledger/cactus@ webpack:dev <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>
<span class="pl-k">&gt;</span> node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js --display-error-details --env env-csv=dev --env target-csv=node

<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:371
                                                        <span class="pl-k">if</span> (item) flattenedResult.push(...item)<span class="pl-k">;</span>
                                                                                  ^

RangeError: Maximum call stack size exceeded
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:371:34
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)
    at <span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/webpack/lib/ContextModuleFactory.js:374:7
    at <span class="pl-k">done</span> (<span class="pl-k">*</span>REDACTED_PATH<span class="pl-k">*</span>/node_modules/neo-async/async.js:2931:13)</pre></div>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<ol dir="auto">
<li>Clone the repo where the failure can be reproduced: <a href="https://github.com/petermetz/blockchain-integration-framework/tree/build/webpack-optimization-139">https://github.com/petermetz/blockchain-integration-framework/tree/build/webpack-optimization-139</a></li>
<li>Check out the branch called <code class="notranslate">build/webpack-optimization-139</code></li>
<li>Execute <code class="notranslate">npm run configure</code> which will produce the crash logs stated above.</li>
<li>You can observe the effective webpack config file after the build has run at least once at <code class="notranslate">./webpack.config.json</code></li>
</ol>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">Build succeeds without RangeError.</p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  <code class="notranslate">v5.4.0</code><br>
Node.js version: <code class="notranslate">v12.16.3</code><br>
Operating System: <code class="notranslate">Ubuntu 20.04 LTS</code><br>
Additional tools: <code class="notranslate">Lerna, Typescript, ts-loader</code></p>