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

fix(provider/selfhosted): defer local connection dial until visitor request arrives

Chiusa
#59 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Read internal/provider/selfhosted.go, especially proxyRequest, and trace how standby tunnel connections receive visitor data. Start by checking how the tunnel connection is read and how local dialing is currently triggered; add a unit test that keeps a standby connection idle and verifies no local socket is opened. Done when local dialing waits for visitor request data and the test passes.

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

Descrizione

bug

Description

In internal/provider/selfhosted.go (proxyRequest), when a standby data socket is established with the server, the client immediately dials localhost:localPort before any public visitor has requested the URL:

func (s *SelfHosted) proxyRequest(ctx context.Context, tunnelConn net.Conn, localPort int) {
    defer tunnelConn.Close()

    localAddr := fmt.Sprintf("localhost:%d", localPort)
    var dialer net.Dialer
    localConn, err := dialer.DialContext(ctx, "tcp", localAddr) // <--- connects immediately!

Problem & Impact

  1. Premature Local Connection: If the standby pool maintains 10 pre-warmed sockets to the VPS, 10 idle connections are immediately opened to the user's local application (e.g. localhost:3000).
  2. Stale Connection Failures: Many local development servers (e.g., Node/Express, Go http.Server.ReadTimeout, Python dev servers) close idle keep-alive connections after a few seconds of silence. If the connection sits idle on localhost waiting for a visitor, the local server closes it. When a visitor finally arrives through the VPS, the proxy attempts to forward bytes over a dead local socket, resulting in an immediate broken pipe and a 502 Bad Gateway response.

Proposed Solution

Defer connecting to localhost:localPort until the first byte(s) of the HTTP request actually arrive over tunnelConn, or peek/read before dialing localhost.

Acceptance Criteria

  • Do not hold open idle connections to localhost before visitor traffic arrives.
  • Ensure local connection is dialed just-in-time when visitor request data is received.
  • Add unit test verifying that idle standby connections do not exhaust local server sockets.
Lingua principale
Go
Stelle
9
Fork
1
Merge medio
5h 57m
PR unite (30g)
15

Preparare l'ambiente

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 kernelshard/expose

Tutte le issue di kernelshard/expose

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.