diff --git a/src/utils/Idler.tsx b/src/utils/Idler.tsx index 21a994cf5..588d63fa3 100644 --- a/src/utils/Idler.tsx +++ b/src/utils/Idler.tsx @@ -25,7 +25,7 @@ export class Idler implements BaseIdler { return this.kill || performance.now() - this.lastIdle > this.interval; } - idle(): Promise { + async idle(): Promise { if (this.kill) { throw new CancelledPromiseError('Idler got killed'); } @@ -34,7 +34,7 @@ export class Idler implements BaseIdler { this.lastIdle = now; return new Promise(resolve => setTimeout(resolve, 0)); } - return Promise.resolve(); + return undefined; } cancel() { diff --git a/src/utils/serialization.tsx b/src/utils/serialization.tsx index 569c44eb2..a3afe89fb 100644 --- a/src/utils/serialization.tsx +++ b/src/utils/serialization.tsx @@ -136,7 +136,7 @@ export async function makeObjectSerializable( let prevStackLength = stack.length; let accumulator = prevStackLength; while (stack.length > 0) { - if (idler) { + if (idler && idler.shouldIdle()) { await idler.idle(); } const element = stack[stack.length - 1];