Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert workaround for bug in nodejs 20.5 #905

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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++
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Nodejs 20.6 this is called more than once...

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
Loading