Skip to content

Commit

Permalink
Merge pull request #1040 from wakatime/feature/recover-close-db
Browse files Browse the repository at this point in the history
Recover from panic when closing db
  • Loading branch information
gandarez committed Apr 4, 2024
2 parents 6a3fd24 + c1f4340 commit 1fd560a
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)
}
}()

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

0 comments on commit 1fd560a

Please sign in to comment.