From 21c26a7aa5f1979d595ae7662683a3787107401b Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Tue, 21 Mar 2023 17:26:06 -0700 Subject: [PATCH] Guard against invalid push server response as an addition check for #2855 --- notifications/browser/browser.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/notifications/browser/browser.go b/notifications/browser/browser.go index 0740d777f..6d97a7949 100644 --- a/notifications/browser/browser.go +++ b/notifications/browser/browser.go @@ -76,10 +76,15 @@ func (b *Browser) Send( return false, errors.Wrap(err, "error sending browser push notification") } + if resp == nil { + return false, errors.New("no response from web push server") + } + + defer resp.Body.Close() + if resp.StatusCode == 410 { return true, nil } - defer resp.Body.Close() return false, err }