Skip to content

Commit dae48dd

Browse files
authored
fix: await result of receiving blocks (#213)
`bitswap._receiveMessage` is an async function so you need to `await` on it in order to correctly handle any errors encountered. I've been seeing `unhandledPromiseRejection` events during test runs, turns out it's when you spin up two nodes, get them to dial each other and transfer data - the tests can shut the nodes down and clean up their repos before they've finished processing incoming blocks leading to `Error: ENOENT: no such file or directory` errors as the repos are deleted out from under the blockstore. `await`ing on the result of `bitswap._receiveMessage` fixes this by handling the error.
1 parent 871e6b3 commit dae48dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Network {
7777
for await (const data of source) {
7878
try {
7979
const message = await Message.deserialize(data.slice())
80-
this.bitswap._receiveMessage(connection.remotePeer, message)
80+
await this.bitswap._receiveMessage(connection.remotePeer, message)
8181
} catch (err) {
8282
this.bitswap._receiveError(err)
8383
break

0 commit comments

Comments
 (0)