You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a project with cyclic imports, top-level await leads to a massive complexity explosion. On a complete graph of n nodes, the time and memory grows as Θ(n!), which gets very bad quickly.
If the current behavior is a bug, please provide the steps to reproduce.
Create the following file as 0.js:
exportconstc=awaitnull;
Create the following file as 1.js, and copy it to 2.js, 3.js, 4.js, 5.js, 6.js, 7.js, 8.js, 9.js and src.js:
@vankop Your screenshot shows that you’ve copied the 29-byte file ten times. The recipe I gave above has one 29-byte file, and ten copies of the 170-byte file. Like this:
In fact, cyclic imports are not necessary to reproduce this. Here’s an example with 24 modules taking 12 seconds and 1.9 gigabytes, with 223 − 1 = 8388607 calls to whenAll.
Bug report
What is the current behavior?
In a project with cyclic imports, top-level
await
leads to a massive complexity explosion. On a complete graph of n nodes, the time and memory grows as Θ(n!), which gets very bad quickly.If the current behavior is a bug, please provide the steps to reproduce.
Create the following file as
0.js
:Create the following file as
1.js
, and copy it to2.js
,3.js
,4.js
,5.js
,6.js
,7.js
,8.js
,9.js
andsrc.js
:(Note that none of the import cycles pass through
0.js
, so this should be fine.)Run
webpack --mode=development --experiments-top-level-await
. (No additional configuration file is needed.)Run
'time' node dist/main.js
.As you can see, this takes over 7 seconds and 1.2 gigabytes of memory.
If you insert a
console.log
statement into thewhenAll
function indist/main.js
, you’ll see that it gets called exactly ⌊10! ⋅ e⌋ − 1 = 9864100 times.What is the expected behavior?
This should run almost immediately with very little memory.
Other relevant information:
webpack version: 5.72.0
Node.js version: 16.15.0
Operating System: NixOS 22.05
Additional tools:
The text was updated successfully, but these errors were encountered: