From a47ddd92e696c5e751778abbf4241bea52ceea9c Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 6 Sep 2023 17:35:44 +0100 Subject: [PATCH] fix: revert workaround for bug in nodejs 20.5 (#905) This PR reverts the workaround for the [bug](https://github.com/nodejs/node/issues/48916) in nodejs 20.5 (and below) which was [resolved](https://github.com/nodejs/node/pull/48935) in nodejs 20.6. --------- Co-authored-by: Travis Vachon --- packages/upload-client/src/car.js | 10 ---------- packages/upload-client/test/store.test.js | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/upload-client/src/car.js b/packages/upload-client/src/car.js index 2749da4ee..34c734309 100644 --- a/packages/upload-client/src/car.js +++ b/packages/upload-client/src/car.js @@ -42,16 +42,6 @@ export class BlockStream extends ReadableStream { let blocksPromise = null const getBlocksIterable = () => { if (blocksPromise) return blocksPromise - // FIXME: remove when resolved: https://github.com/nodejs/node/issues/48916 - /* c8 ignore next 10 */ - if (parseInt(globalThis.process?.versions?.node) > 18) { - blocksPromise = (async () => { - // @ts-expect-error - const bytes = await car.arrayBuffer() - return CarBlockIterator.fromBytes(new Uint8Array(bytes)) - })() - return blocksPromise - } blocksPromise = CarBlockIterator.fromIterable(toIterable(car.stream())) return blocksPromise } diff --git a/packages/upload-client/test/store.test.js b/packages/upload-client/test/store.test.js index 11b348f34..65ac1b9e3 100644 --- a/packages/upload-client/test/store.test.js +++ b/packages/upload-client/test/store.test.js @@ -59,7 +59,7 @@ describe('Store.add', () => { channel: server, }) - let progressStatusCalls = 0 + let loaded = 0 const carCID = await Store.add( { issuer: agent, with: space.did(), proofs, audience: serviceSigner }, car, @@ -67,14 +67,14 @@ describe('Store.add', () => { connection, onUploadProgress: (status) => { assert(typeof status.loaded === 'number' && status.loaded > 0) - progressStatusCalls++ + loaded = status.loaded }, } ) assert(service.store.add.called) assert.equal(service.store.add.callCount, 1) - assert.equal(progressStatusCalls, 1) + assert.equal(loaded, 225) assert(carCID) assert.equal(carCID.toString(), car.cid.toString())