chore: Catch heads iterator errors.

This commit is contained in:
Hayden Young 2023-10-11 23:03:22 +01:00
parent 3b3f90501c
commit 0c3e7667f3

View File

@ -142,15 +142,23 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
let started = false let started = false
const onPeerJoined = async (peerId) => { const onPeerJoined = async (peerId) => {
const heads = await log.heads() try {
events.emit('join', peerId, heads) const heads = await log.heads()
events.emit('join', peerId, heads)
} catch (err) {
console.log('onPeerJoined', ipfs.libp2p.peerId.toString())
}
} }
const sendHeads = async (source) => { const sendHeads = async (source) => {
return (async function * () { return (async function * () {
const heads = await log.heads() try {
for await (const { bytes } of heads) { const heads = await log.heads()
yield bytes for await (const { bytes } of heads) {
yield bytes
}
} catch (err) {
console.log('onPeerJoined', ipfs.libp2p.peerId.toString())
} }
})() })()
} }