From e940c89f2f10ef1749a8c407446bdfa7b0c616c0 Mon Sep 17 00:00:00 2001 From: dholms Date: Fri, 17 Nov 2023 14:55:23 -0600 Subject: [PATCH] use setImmediate --- packages/repo/src/util.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/repo/src/util.ts b/packages/repo/src/util.ts index 686bad560cf..7165ad005fe 100644 --- a/packages/repo/src/util.ts +++ b/packages/repo/src/util.ts @@ -1,4 +1,5 @@ import { CID } from 'multiformats/cid' +import { setImmediate } from 'node:timers/promises' import * as cbor from '@ipld/dag-cbor' import { CarBlockIterator } from '@ipld/car' import { BlockWriter, CarWriter } from '@ipld/car/writer' @@ -11,7 +12,6 @@ import { cidForCbor, byteIterableToStream, TID, - wait, } from '@atproto/common' import { ipldToLex, lexToIpld, LexValue, RepoRecord } from '@atproto/lexicon' @@ -102,13 +102,10 @@ export const carToBlocks = async ( } const blocks = new BlockMap() if (car._iterable) { - let count = 0 for await (const block of car._iterable) { blocks.set(block.cid, block.bytes) - count++ - if (count % 10000 === 0) { - await wait(1) - } + // break up otherwise "synchronous" work + await setImmediate() } } return {