3 ms·
> and where you're awaiting That is the sole source of the issue, and exactly what the comment you're replying to talks about. The problem is that `a += b` de
by masklinn 4y ago
> and where you're awaiting
That is the sole source of the issue, and exactly what the comment you're replying to talks about.
The problem is that `a += b` desugars to `a = a + b`, so if `b` is an await you get
totalSize = totalSize + await file.getSize();
Since javascript evaluates left to right, it first evaluates `totalSize`, gets zero, then `file.getSize()`, then suspends waiting for the result... at which point the handler for the next file can run, doing the exact same thing, repeat for all files.