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: tests in CI #1034

Merged
merged 17 commits into from Feb 24, 2022
Merged
21,447 changes: 13,423 additions & 8,024 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/client/package.json
Expand Up @@ -31,18 +31,18 @@
},
"dependencies": {
"@ipld/car": "^3.1.4",
"@web-std/blob": "^3.0.1",
"@web-std/fetch": "^3.0.0",
"@web-std/file": "^3.0.0",
"@web-std/blob": "^3.0.3",
"@web-std/fetch": "^3.0.3",
"@web-std/file": "^3.0.2",
"@web3-storage/parse-link-header": "^3.1.0",
"browser-readablestream-to-it": "^1.0.3",
"carbites": "^1.0.6",
"cborg": "^1.6.0",
"files-from-path": "^0.2.3",
"ipfs-car": "^0.6.1",
"ipfs-car": "^0.6.2",
"ipns": "^0.16.0",
"libp2p-crypto": "^0.21.0",
"p-retry": "^4.5.0",
"parse-link-header": "^2.0.0",
"streaming-iterables": "^6.0.0",
"uint8arrays": "^3.0.0"
},
Expand All @@ -52,7 +52,6 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/mocha": "9.0.0",
"@types/parse-link-header": "^1.0.1",
"bundlesize": "^0.18.1",
"cors": "^2.8.5",
"del-cli": "^4.0.0",
Expand All @@ -62,6 +61,7 @@
"npm-run-all": "^4.1.5",
"nyc": "15.1.0",
"playwright-test": "^7.2.2",
"randombytes": "^2.1.0",
"rollup": "2.63.0",
"rollup-plugin-multi-input": "1.3.1",
"rollup-plugin-terser": "^7.0.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/lib.js
Expand Up @@ -16,7 +16,7 @@
import { transform } from 'streaming-iterables'
import pRetry from 'p-retry'
import { pack } from 'ipfs-car/pack'
import parseLink from 'parse-link-header'
import { parseLinkHeader } from '@web3-storage/parse-link-header'
import { unpackStream } from 'ipfs-car/unpack'
import { TreewalkCarSplitter } from 'carbites/treewalk'
import { CarReader } from '@ipld/car'
Expand Down Expand Up @@ -469,13 +469,13 @@ function toWeb3Response (res) {
async function * paginator (fn, service, opts) {
let res = await fn(service, opts)
yield res
let link = parseLink(res.headers.get('Link') || '')
let link = parseLinkHeader(res.headers.get('Link') || '')
// @ts-ignore
while (link && link.next) {
// @ts-ignore
res = await fn(service, link.next)
yield res
link = parseLink(res.headers.get('Link') || '')
link = parseLinkHeader(res.headers.get('Link') || '')
}
}

Expand Down
24 changes: 22 additions & 2 deletions packages/client/test/put.spec.js
Expand Up @@ -9,6 +9,7 @@ import { CID } from 'multiformats/cid'
import { encode } from 'multiformats/block'
import * as json from '@ipld/dag-json'
import { sha256 } from 'multiformats/hashes/sha2'
import { ReadableStream } from '@web-std/blob'

describe('put', () => {
const { AUTH_TOKEN, API_PORT } = process.env
Expand Down Expand Up @@ -85,12 +86,31 @@ describe('put', () => {
})

it('adds big files', async function () {
this.timeout(30e3)
this.timeout(60e3)
const client = new Web3Storage({ token, endpoint })
let uploadedChunks = 0

const files = [
new File([randomBytes(1024e6)], '102mb.txt')
// Previously: new File([randomBytes(1024e6)], '102mb.txt')
//
// Node.js currently copies the buffer on every iteration when obtaining a
// stream from File.stream(). It also has a fixed and small chunk size of
// 65536 bytes. This makes reading the stream VERY slow and this test
// fails because it times out.
//
// TODO: revert to using File if this issue gets resolved:
// https://github.com/nodejs/node/issues/42108
{
name: '102mb.txt',
stream () {
return new ReadableStream({
pull (controller) {
controller.enqueue(randomBytes(1024e6))
controller.close()
}
})
}
}
]

await client.put(files, {
Expand Down
1 change: 0 additions & 1 deletion packages/website/next-env.d.ts
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
2 changes: 1 addition & 1 deletion packages/website/package.json
Expand Up @@ -16,7 +16,7 @@
"filesize": "^6.1.0",
"gray-matter": "^4.0.3",
"magic-sdk": "^4.2.1",
"next": "^11.0.1",
"next": "^12.1.0",
"p-map": "^5.1.0",
"pretty-bytes": "^5.6.0",
"rc-tooltip": "^5.1.1",
Expand Down
23 changes: 18 additions & 5 deletions packages/website/tsconfig.json
Expand Up @@ -4,7 +4,10 @@
"allowJs": true,
"checkJs": true,
"target": "esnext",
"lib": ["ESNext", "DOM"],
"lib": [
"ESNext",
"DOM"
],
"strict": true,
"moduleResolution": "node",
"sourceMap": true,
Expand All @@ -17,11 +20,21 @@
"resolveJsonModule": true,
"isolatedModules": true,
"paths": {
"web3.storage": ["../client"]
}
"web3.storage": [
"../client"
]
},
"incremental": true
},
"include": ["lib", "pages", "components"],
"exclude": ["node_modules/", ".next/"],
"include": [
"lib",
"pages",
"components"
],
"exclude": [
"node_modules/",
".next/"
],
"references": [
{
"path": "../client"
Expand Down