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.
This commit is contained in:
Ted Unangst 2019-08-02 10:45:42 -04:00
parent 2ef8cc8a80
commit 2a197e157c
2 changed files with 12 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
notrand "math/rand"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -473,6 +474,15 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
obj, err = GetJunk(xid) obj, err = GetJunk(xid)
if err != nil { if err != nil {
log.Printf("error regetting: %s", err) 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) origin = originate(xid)
what = "bonk" what = "bonk"

View File

@ -2,6 +2,8 @@ changelog
-- next -- next
+ Add another retry to workaround pixelfed's general unreliability.
+ Attached images are not lost when previewing. + Attached images are not lost when previewing.
- Remove sensitivity to spicy peppers. - Remove sensitivity to spicy peppers.