Skip to content

Commit

Permalink
Context cancellation handling (#131)
Browse files Browse the repository at this point in the history
* Return connect() when context is cancelled

* Check ctx.Err() is err.canceled

* Allow to run PostDisconnectCallback
  • Loading branch information
nobl9-adam-szymanski authored Aug 24, 2021
1 parent df8ce38 commit 5defcae
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions signalflow/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func (c *wsConn) Run() {
c.PostDisconnectCallback()
}

if c.ctx.Err() == context.Canceled {
log.Printf("Context cancelled, stop reconnecting.")
return
}

var err error
conn, err = c.connect()
if err != nil {
Expand Down

0 comments on commit 5defcae

Please sign in to comment.