Skip to content

Commit

Permalink
fix: revert workaround for bug in nodejs 20.5 (#905)
Browse files Browse the repository at this point in the history
This PR reverts the workaround for the
[bug](nodejs/node#48916) in nodejs 20.5 (and
below) which was [resolved](nodejs/node#48935)
in nodejs 20.6.

---------

Co-authored-by: Travis Vachon <[email protected]>
  • Loading branch information
Alan Shaw and travis authored Sep 6, 2023
1 parent 3c5fbac commit a47ddd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
10 changes: 0 additions & 10 deletions packages/upload-client/src/car.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions packages/upload-client/test/store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ 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,
{
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())
Expand Down

0 comments on commit a47ddd9

Please sign in to comment.