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: support for Node.js 20 #840

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion .github/workflows/access-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node_version:
- 18
- 20
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/aggregate-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node_version:
- 18
- 20
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/upload-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node_version:
- 18
- 20
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/w3up-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node_version:
- 18
- 20
defaults:
run:
working-directory: ./packages/w3up-client
Expand All @@ -29,7 +34,7 @@ jobs:
- name: Setup
uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ matrix.node_version }}
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
- run: pnpm --filter '@web3-storage/w3up-client...' install
Expand Down
14 changes: 12 additions & 2 deletions packages/upload-client/src/car.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ 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 Expand Up @@ -77,11 +87,11 @@ export class BlockStream extends ReadableStream {
* @param {{ getReader: () => ReadableStreamDefaultReader<T> } | AsyncIterable<T>} stream
* @returns {AsyncIterable<T>}
*/
/* c8 ignore next 16 */
function toIterable(stream) {
return Symbol.asyncIterator in stream
? stream
: /* c8 ignore next 12 */
(async function* () {
: (async function* () {
const reader = stream.getReader()
try {
while (true) {
Expand Down