diff --git a/desktop/app/src/utils/serialization.tsx b/desktop/app/src/utils/serialization.tsx index 11c3eda6e..d646389c6 100644 --- a/desktop/app/src/utils/serialization.tsx +++ b/desktop/app/src/utils/serialization.tsx @@ -140,9 +140,6 @@ export async function makeObjectSerializable( let prevStackLength = stack.length; let accumulator = prevStackLength; while (stack.length > 0) { - if (idler && idler.shouldIdle()) { - await idler.idle(); - } const element = stack[stack.length - 1]; if (element instanceof Map) { const {childNeedsIteration, outputArray} = processMapElement( @@ -202,13 +199,16 @@ export async function makeObjectSerializable( ++numIterations; accumulator += stack.length >= prevStackLength ? stack.length - prevStackLength + 1 : 0; - const percentage = (numIterations / accumulator) * 100; - statusUpdate && - statusUpdate( - `${ - statusMsg || 'Serializing Flipper ' - }: ${numIterations} / ${accumulator} (${percentage.toFixed(2)}%) `, - ); + if (idler && idler.shouldIdle()) { + const percentage = (numIterations / accumulator) * 100; + statusUpdate && + statusUpdate( + `${ + statusMsg || 'Serializing Flipper ' + }: ${numIterations} / ${accumulator} (${percentage.toFixed(2)}%) `, + ); + await idler.idle(); + } prevStackLength = stack.length; } return dict.get(obj);