Skip to content

Commit

Permalink
fix the bundling progress bar stuck at 100% (#1445)
Browse files Browse the repository at this point in the history
Summary:

X-link: facebook/react-native#49750

Changelog: [General][Internal] fix the bundling progress bar stuck at 100%

Plus some minor ui improvements in the initial logging

Differential Revision: D70381801
  • Loading branch information
vzaidman authored and facebook-github-bot committed Feb 28, 2025
1 parent 5b4d8cb commit ececa29
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/metro/src/lib/TerminalReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,13 @@ class TerminalReporter {
}
/**
* We use Math.pow(ratio, 2) to as a conservative measure of progress because
* we know the `totalCount` is going to progressively increase as well. We
* also prevent the ratio from going backwards.
* Since `totalCount` progressively increases, we don't allow
* the progress bar to raise above 15% before 30 files are transformed,
* by which point in most cases there will be a relatively realistic ratio
* calculated compared with the rates in the beginning of the process
* where 1/2 files already gets us to 50%.
* Also, for better progress indication, don't allow the progress
* to go backwards.
*/
_updateBundleProgress({
buildID,
Expand All @@ -373,9 +377,12 @@ class TerminalReporter {
if (currentProgress == null) {
return;
}
const rawRatio = transformedFileCount / totalFileCount;
const conservativeRatio = Math.pow(rawRatio, 2);
const ratio = Math.max(conservativeRatio, currentProgress.ratio);
const ratio = Math.max(
transformedFileCount / totalFileCount,
transformedFileCount < 30 ? 0.15 : currentProgress.ratio,
);
Object.assign(currentProgress, {
ratio,
transformedFileCount,
Expand Down

0 comments on commit ececa29

Please sign in to comment.