Skip to content

Commit

Permalink
fix: set libp2p status to started before stopping (#2288)
Browse files Browse the repository at this point in the history
In order to stop components that have been started during a failed
startup, set the current status to started after catching the
error - `this.stop` will immediately set it to `stopping`.
  • Loading branch information
achingbrain authored Dec 2, 2023
1 parent 5a9362e commit 09dd029
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/libp2p/src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends
this.log('libp2p has started')
} catch (err: any) {
this.log.error('An error occurred starting libp2p', err)
// set status to 'started' so this.stop() will stop any running components
this.status = 'started'
await this.stop()
throw err
}
Expand Down

0 comments on commit 09dd029

Please sign in to comment.