Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 43e308e

Browse files
committed
chore: fix ipfs-client tests
1 parent 10f0eb4 commit 43e308e

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

packages/ipfs-grpc-client/src/core-api/files/write.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const {
1313
* @param {*} content
1414
*/
1515
async function * stream (path, content) {
16-
yield { path, content: normaliseContent(content) }
16+
for await (const buf of normaliseContent(content)) {
17+
yield { path, content: buf }
18+
}
1719
}
1820

1921
/**

packages/ipfs-grpc-client/src/grpc/transport.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ function websocketRequest (options) {
112112
}
113113

114114
ws.onmessage = function (e) {
115-
if (e.data instanceof Uint8Array) {
115+
if (e.data instanceof ArrayBuffer) {
116116
options.onChunk(new Uint8Array(e.data, 0, e.data.byteLength))
117117
} else {
118-
options.onEnd(new Error(`Incorrect message type received - expected Uint8Array, got ${typeof e.data}`))
118+
options.onEnd(new Error(`Incorrect message type received - expected ArrayBuffer, got ${typeof e.data}`))
119119
ws.close()
120120
}
121121
}

packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ module.exports = function bidiToDuplex (grpc, service, options) {
5353
status
5454
})
5555

56-
err.stack = trailers.get('grpc-stack')[0] || error.stack
56+
let stack = trailers.get('grpc-stack')[0]
57+
stack = stack && stack.replace(/\\n/g, '\n')
58+
59+
err.stack = stack || error.stack
5760
}
5861

5962
sink.end(err)

packages/ipfs-grpc-client/src/utils/to-headers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
'use strict'
22

33
const { paramCase } = require('change-case')
4-
const { grpc: { Metadata } } = require('@improbable-eng/grpc-web')
54

65
/**
76
* @param {Record<string, any>} [object] - key/value pairs to turn into HTTP headers
8-
**/
7+
*/
98
module.exports = (object = {}) => {
10-
const output = new Metadata()
9+
/** @type {Record<string, string>} */
10+
const output = {}
1111

1212
Object.keys(object || {}).forEach(key => {
1313
if (typeof object[key] === 'function') {
1414
return
1515
}
1616

17-
output.set(paramCase(key), object[key])
17+
output[paramCase(key)] = object[key].toString()
1818
})
1919

2020
return output

0 commit comments

Comments
 (0)