From 2a197e157cffb764f5de67d6c575edd600c73132 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 2 Aug 2019 10:45:42 -0400 Subject: [PATCH] every time I try to get a post from pixelfed, I get a 502 error. workaround by sleeping and trying again when the PHP cools down. --- activity.go | 10 ++++++++++ docs/changelog.txt | 2 ++ 2 files changed, 12 insertions(+) diff --git a/activity.go b/activity.go index b6b1c29..9684c6e 100644 --- a/activity.go +++ b/activity.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "log" + notrand "math/rand" "net/http" "net/url" "os" @@ -473,6 +474,15 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk { obj, err = GetJunk(xid) if err != nil { log.Printf("error regetting: %s", err) + if err.Error() == "http get status: 502" { + time.Sleep(time.Duration(60+notrand.Int63n(60)) * time.Second) + obj, err = GetJunk(xid) + if err != nil { + log.Printf("still couldn't get it") + } else { + log.Printf("retry success!") + } + } } origin = originate(xid) what = "bonk" diff --git a/docs/changelog.txt b/docs/changelog.txt index 2b33f05..48c9137 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Add another retry to workaround pixelfed's general unreliability. + + Attached images are not lost when previewing. - Remove sensitivity to spicy peppers.