Skip to content

Commit

Permalink
Recover from panic when closing db
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Apr 4, 2024
1 parent 6a3fd24 commit c1f4340
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/offline/offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ func openDB(filepath string) (db *bolt.DB, _ func(), err error) {
}

return db, func() {
// recover from panic when closing db
defer func() {
if r := recover(); r != nil {
log.Warnf("panicked: failed to close db file: %v", r)
}

Check warning on line 418 in pkg/offline/offline.go

View check run for this annotation

Codecov / codecov/patch

pkg/offline/offline.go#L417-L418

Added lines #L417 - L418 were not covered by tests
}()

if err := db.Close(); err != nil {
log.Debugf("failed to close db file: %s", err)
}
Expand Down

0 comments on commit c1f4340

Please sign in to comment.