Skip to content

Commit a47ddd9

Browse files
Alan ShawTravis Vachon
andauthored
fix: revert workaround for bug in nodejs 20.5 (#905)
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]>
1 parent 3c5fbac commit a47ddd9

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

packages/upload-client/src/car.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ export class BlockStream extends ReadableStream {
4242
let blocksPromise = null
4343
const getBlocksIterable = () => {
4444
if (blocksPromise) return blocksPromise
45-
// FIXME: remove when resolved: https://github.com/nodejs/node/issues/48916
46-
/* c8 ignore next 10 */
47-
if (parseInt(globalThis.process?.versions?.node) > 18) {
48-
blocksPromise = (async () => {
49-
// @ts-expect-error
50-
const bytes = await car.arrayBuffer()
51-
return CarBlockIterator.fromBytes(new Uint8Array(bytes))
52-
})()
53-
return blocksPromise
54-
}
5545
blocksPromise = CarBlockIterator.fromIterable(toIterable(car.stream()))
5646
return blocksPromise
5747
}

packages/upload-client/test/store.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,22 @@ describe('Store.add', () => {
5959
channel: server,
6060
})
6161

62-
let progressStatusCalls = 0
62+
let loaded = 0
6363
const carCID = await Store.add(
6464
{ issuer: agent, with: space.did(), proofs, audience: serviceSigner },
6565
car,
6666
{
6767
connection,
6868
onUploadProgress: (status) => {
6969
assert(typeof status.loaded === 'number' && status.loaded > 0)
70-
progressStatusCalls++
70+
loaded = status.loaded
7171
},
7272
}
7373
)
7474

7575
assert(service.store.add.called)
7676
assert.equal(service.store.add.callCount, 1)
77-
assert.equal(progressStatusCalls, 1)
77+
assert.equal(loaded, 225)
7878

7979
assert(carCID)
8080
assert.equal(carCID.toString(), car.cid.toString())

0 commit comments

Comments
 (0)