Skip to content

Commit

Permalink
fix: switch upload-api to node16 (#509)
Browse files Browse the repository at this point in the history
Running tests in w3infra failed because `Blob` is not in node16. Change
ci to use node 16 for upload-api to avoid this problem.
  • Loading branch information
Gozala authored Mar 8, 2023
1 parent 544a838 commit 698a033
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/upload-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 16
registry-url: https://registry.npmjs.org/
cache: 'pnpm'

Expand All @@ -60,7 +60,7 @@ jobs:
- name: Setup
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 16
registry-url: https://registry.npmjs.org/
cache: 'pnpm'

Expand Down
28 changes: 25 additions & 3 deletions packages/upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"version": "1.0.2",
"type": "module",
"main": "./src/lib.js",
"files": [
"src",
"test",
"dist/src/**/*.d.ts",
"dist/src/**/*.d.ts.map"
],
"typesVersions": {
"*": {
"src/lib.js": [
Expand Down Expand Up @@ -48,8 +54,8 @@
"build": "tsc --build",
"check": "tsc --build",
"lint": "tsc --build",
"test": "mocha --bail --timeout 10s -n no-warnings -n experimental-vm-modules test/**/*.spec.js",
"test-watch": "pnpm build && mocha --bail --timeout 10s --watch --parallel -n no-warnings -n experimental-vm-modules --watch-files src,test"
"test": "mocha --bail --timeout 10s -n no-warnings -n experimental-vm-modules -n experimental-fetch test/**/*.spec.js",
"test-watch": "pnpm build && mocha --bail --timeout 10s --watch --parallel -n no-warnings -n experimental-vm-modules -n experimental-fetch --watch-files src,test"
},
"dependencies": {
"@ucanto/client": "^5.1.0",
Expand All @@ -66,7 +72,9 @@
"@types/mocha": "^10.0.1",
"@ucanto/core": "^5.1.0",
"@web3-storage/sigv4": "^1.0.2",
"mocha": "^10.2.0"
"@web-std/blob": "^3.0.4",
"mocha": "^10.2.0",
"hd-scripts": "^4.1.0"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -104,6 +112,20 @@
"coverage"
]
},
"depcheck": {
"specials": [
"bin"
],
"ignorePatterns": [
"dist"
],
"ignores": [
"dist",
"@types/*",
"hd-scripts",
"eslint-config-prettier"
]
},
"engines": {
"node": ">=16.15"
}
Expand Down
8 changes: 7 additions & 1 deletion packages/upload-api/test/car-store-bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class CarStoreBucket {
}

response.end()
// otherwise it keep connection lingering
response.destroy()
})
await new Promise((resolve) => server.listen(resolve))

Expand Down Expand Up @@ -80,7 +82,11 @@ export class CarStoreBucket {
*/
deactivate() {
return new Promise((resolve, reject) => {
this.server.closeAllConnections()
// does not exist in node 16
if (typeof this.server.closeAllConnections === 'function') {
this.server.closeAllConnections()
}

this.server.close((error) => {
if (error) {
reject(error)
Expand Down
1 change: 1 addition & 0 deletions packages/upload-api/test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { sha256 } from 'multiformats/hashes/sha2'
import * as CAR from '@ucanto/transport/car'
import * as raw from 'multiformats/codecs/raw'
import { CarWriter } from '@ipld/car'
import { Blob } from '@web-std/blob'

/** did:key:z6Mkk89bC3JrVqKie71YEcc5M1SMVxuCgNx6zLZ8SYJsxALi */
export const alice = ed25519.parse(
Expand Down
39 changes: 34 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 698a033

Please sign in to comment.