Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 2cf6f1f

Browse files
committed
Merge pull request #11 from ipfs/fix/error
fix(block-service): return errors for addBlock
2 parents d3e6baf + 0fea48d commit 2cf6f1f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/block-service.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ const async = require('async')
1010
function BlockService (ipfsRepo, exchange) {
1111
this.addBlock = (block, callback) => {
1212
const ws = ipfsRepo.datastore.createWriteStream(block.key, block.extension)
13+
14+
let done = false
15+
1316
ws.write(block.data)
14-
ws.once('finish', callback)
17+
ws.once('error', (err) => {
18+
done = true
19+
callback(err)
20+
})
21+
ws.once('finish', () => {
22+
if (!done) callback()
23+
})
1524
ws.end()
1625
}
1726

0 commit comments

Comments
 (0)