Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

forward: 1006 reconnect never triggers (wrapped error vs IsCloseError), and exits with a usage dump

Aperta
#43 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@ryux1 ci sta già lavorando.

Dal 7/9/2026.

  • #45 di @ryux1 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli, networking

Direzione di ricerca

Inizia da webhook/forward.go, leggendo runFwd e handleWebsocket per tracciare come l'errore websocket avvolto raggiunge il controllo del retry. Verifica che le chiusure anomale effettuino un retry invece di terminare, che gli errori di runtime non stampino il dump dell'utilizzo e che il comportamento dopo sessioni ripetute o prolungate corrisponda al ciclo di vita previsto del forwarder.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

gh webhook forward has retry logic for a 1006 abnormal closure, but it never runs. The error is wrapped before it reaches the check, and websocket.IsCloseError does not unwrap. The result is that the command exits on the first server-side disconnect — and, because the command sets neither SilenceUsage nor SilenceErrors, prints its entire help text on the way out.

In my case GitHub closes the forwarding socket roughly every five minutes, so a long-running forward dies about twelve times an hour and each death writes ~26 lines of usage output. 73% of my log is cobra help text.

The cause

webhook/forward.go, in runFwd:

for i := 0; i < 3; i++ {
    err := handleWebsocket(out, url, token, wsURL, activateHook)
    if err != nil {
        // If the error is a server disconnect (1006), retry connecting
        if websocket.IsCloseError(err, websocket.CloseAbnormalClosure) {
            time.Sleep(5 * time.Second)
            continue
        }
        ...
        return err
    }
}

handleWebsocket wraps the read error before returning it:

err := c.ReadJSON(&ev)
if err != nil {
    return fmt.Errorf("error receiving json event: %w", err)
}

and gorilla/websocket v1.5.0's IsCloseError is a bare type assertion, not errors.As:

func IsCloseError(err error, codes ...int) bool {
	if e, ok := err.(*CloseError); ok {

So the assertion fails on the wrapped error, the continue is unreachable, and runFwd returns immediately. The observed error confirms it — this is the wrapped text, not unable to connect to webhooks server, forwarding stopped, which is what exhausting the loop would produce:

Error: error receiving json event: websocket: close 1006 (abnormal closure): unexpected EOF
Suggested fix
var closeErr *websocket.CloseError
if errors.As(err, &closeErr) && closeErr.Code == websocket.CloseAbnormalClosure {
    time.Sleep(5 * time.Second)
    continue
}

and SilenceUsage: true on the command, since a runtime network error is not a usage error.

One more thing worth considering

Fixing the unwrap alone may not be enough for a long-running forwarder. i counts total disconnects across the process lifetime and is never reset after a successful session, so with a server that closes on a timer the command would still exit permanently after three closes — for me, about fifteen minutes. Resetting the counter after a session that lasted a meaningful length of time would make forward survivable as a long-running process.

Versions
  • gh 2.98.0
  • gh-webhook v0.2.0
  • macOS 15 (arm64)
Lingua principale
Go
Stelle
43
Fork
18
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cli/gh-webhook

Tutte le issue di cli/gh-webhook

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.