Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#59 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Go
スター
9
フォーク
1
平均マージ
5時間 57分
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

kernelshard/expose のほかの issue

kernelshard/expose の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。