Skip to content

Commit

Permalink
Do'h; do it correct
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Feb 16, 2022
1 parent 0b6b90a commit e59c59b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion handlers/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ func (l *loaderT) sendJSON(r *http.Request, id zint.Uint128, data interface{}) {
defer c.Unlock()
w, err := c.conn.NextWriter(websocket.TextMessage)
if err != nil {
if w != nil {
w.Close()
}
zlog.Fields(zlog.F{
"connectID": id,
"siteID": Site(r.Context()).ID,
"userID": User(r.Context()).ID,
}).FieldsRequest(r).Errorf("loader.send: NextWriter: %s", err)
return
}
defer w.Close()

j, err := json.Marshal(data)
if err != nil {
Expand All @@ -119,6 +121,7 @@ func (l *loaderT) sendJSON(r *http.Request, id zint.Uint128, data interface{}) {
}

_, err = w.Write(j)
w.Close()
if err != nil {
zlog.Fields(zlog.F{
"connectID": id,
Expand Down

0 comments on commit e59c59b

Please sign in to comment.