Skip to content

Commit 2aeec75

Browse files
committed
keep track of unknown crawl errors
1 parent 6682e88 commit 2aeec75

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

discv5/crawler.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ func (c *Crawler) Work(ctx context.Context, task PeerInfo) (core.CrawlResult[Pee
7171
properties["gen_tcp_addr"] = true
7272
}
7373

74+
// keep track of all unknown connection errors
75+
if libp2pResult.ConnectErrorStr == models.NetErrorUnknown && libp2pResult.ConnectError != nil {
76+
properties["connect_error"] = libp2pResult.ConnectError.Error()
77+
}
78+
79+
// keep track of all unknown crawl errors
80+
if discV5Result.ErrorStr == models.NetErrorUnknown && discV5Result.Error != nil {
81+
properties["crawl_error"] = discV5Result.Error.Error()
82+
}
83+
7484
data, err := json.Marshal(properties)
7585
if err != nil {
7686
log.WithError(err).WithField("properties", properties).Warnln("Could not marshal peer properties")
@@ -263,8 +273,6 @@ func (c *Crawler) connect(ctx context.Context, pi peer.AddrInfo) error {
263273
err := c.host.Connect(timeoutCtx, pi)
264274
cancel()
265275

266-
// if we still don't have an error (despite the above custom error
267-
// handling), we return to the caller.
268276
if err == nil {
269277
return nil
270278
}

libp2p/crawler.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/dennis-tra/nebula-crawler/config"
1515
"github.com/dennis-tra/nebula-crawler/core"
16+
"github.com/dennis-tra/nebula-crawler/db/models"
1617
"github.com/dennis-tra/nebula-crawler/kubo"
1718
"github.com/dennis-tra/nebula-crawler/utils"
1819
)
@@ -110,6 +111,16 @@ func mergeResults(r *core.CrawlResult[PeerInfo], p2pRes P2PResult, apiRes APIRes
110111
properties["direct_close"] = true
111112
}
112113

114+
// keep track of all unknown connection errors
115+
if p2pRes.ConnectErrorStr == models.NetErrorUnknown && p2pRes.ConnectError != nil {
116+
properties["connect_error"] = p2pRes.ConnectError.Error()
117+
}
118+
119+
// keep track of all unknown crawl errors
120+
if p2pRes.CrawlErrorStr == models.NetErrorUnknown && p2pRes.CrawlError != nil {
121+
properties["crawl_error"] = p2pRes.CrawlError.Error()
122+
}
123+
113124
var err error
114125
r.Properties, err = json.Marshal(properties)
115126
if err != nil {

0 commit comments

Comments
 (0)