diff --git a/packages/sandbox/daemon-go/internal/probe/probe.go b/packages/sandbox/daemon-go/internal/probe/probe.go index 68ccb8f53a..4c2361bb3b 100644 --- a/packages/sandbox/daemon-go/internal/probe/probe.go +++ b/packages/sandbox/daemon-go/internal/probe/probe.go @@ -27,12 +27,6 @@ type State struct { Status string Port int HtmlSupport bool - // HTTPStatus is the status code of the last successful probe request, or 0 - // when nothing answered. A dev server that answers every request with 5xx - // is reachable but useless — `Status` alone cannot tell those apart, and a - // warm-pool pod handed over with a half-built framework directory looks - // perfectly online without this. - HTTPStatus int } type Deps struct { @@ -137,7 +131,7 @@ func (p *Prober) tick() { } if up { p.consecutiveFailures = 0 - next := State{Status: StatusOnline, Port: p.state.Port, HtmlSupport: isHtml, HTTPStatus: status} + next := State{Status: StatusOnline, Port: p.state.Port, HtmlSupport: isHtml} prevStatus := p.state.Status p.applyLocked(next) if prevStatus == StatusBooting && p.deps.OnLog != nil { diff --git a/packages/sandbox/daemon-go/internal/probe/probe_status_test.go b/packages/sandbox/daemon-go/internal/probe/probe_status_test.go deleted file mode 100644 index 1bf4076c2e..0000000000 --- a/packages/sandbox/daemon-go/internal/probe/probe_status_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package probe - -import ( - "net/http" - "net/http/httptest" - "net/url" - "strconv" - "testing" - "time" -) - -// A dev server answering every request with 500 is reachable, so Status stays -// online — but HTTPStatus must carry the code so a caller can tell the two -// apart. This is the warm-pool handover bug: `.faststore/src/pages` missing, -// every route 500, watchdog silent. -func TestStateCarriesHTTPStatus(t *testing.T) { - for _, code := range []int{200, 500} { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - w.Header().Set("Content-Type", "text/html") - w.WriteHeader(code) - })) - port := serverPort(t, srv.URL) - - got := make(chan State, 8) - p := Start(Deps{ - GetPort: func() int { return port }, - OnChange: func(s State) { got <- s }, - Fast: 5 * time.Millisecond, - Slow: 5 * time.Millisecond, - }) - - var seen State - deadline := time.After(3 * time.Second) - wait: - for { - select { - case s := <-got: - if s.Status == StatusOnline { - seen = s - break wait - } - case <-deadline: - t.Fatalf("code %d: never reported online", code) - } - } - p.Stop() - srv.Close() - - if seen.HTTPStatus != code { - t.Fatalf("code %d: HTTPStatus = %d, want %d", code, seen.HTTPStatus, code) - } - } -} - -func serverPort(t *testing.T, raw string) int { - t.Helper() - u, err := url.Parse(raw) - if err != nil { - t.Fatal(err) - } - n, err := strconv.Atoi(u.Port()) - if err != nil { - t.Fatal(err) - } - return n -} diff --git a/packages/sandbox/daemon-go/main.go b/packages/sandbox/daemon-go/main.go index d8b3819d6c..84de432e62 100644 --- a/packages/sandbox/daemon-go/main.go +++ b/packages/sandbox/daemon-go/main.go @@ -457,14 +457,6 @@ func envDuration(name string, def, min time.Duration) time.Duration { return def } -// restartOn5xx gates treating an all-5xx dev server as dead. Default off: a -// user's app can legitimately 5xx from its own bug, and restarting that fixes -// nothing, so this ships dormant and is enabled per-deployment. -func restartOn5xx() bool { - v := strings.ToLower(strings.TrimSpace(os.Getenv("DEV_RESTART_ON_5XX"))) - return v == "1" || v == "true" -} - // envInt reads an int from env, clamped to at least min, def when unset/bad. func envInt(name string, def, min int) int { if v := os.Getenv(name); v != "" { @@ -492,16 +484,7 @@ func (d *daemon) devWatchTick() { portKnown := sniffed != 0 || lastRunning != 0 // Read synchronously, not via a mirror an out-of-order callback could // leave stale (see probe.Prober.Current). - probeState := d.prober.Current() - serving := probeState.Status == probe.StatusOnline - if serving && restartOn5xx() && probeState.HTTPStatus >= 500 { - // Reachable but serving nothing usable. A warm-pool pod has been handed - // over with a half-built framework directory (every route 5xx) and the - // watchdog sat it out, because "answered the request" was the whole - // liveness test. Treating that as dead lets the existing grace window - // and MaxRestarts budget rebuild it exactly once. - serving = false - } + serving := d.prober.Current().Status == probe.StatusOnline d.devWatchMu.Lock() action := d.devTracker.Observe(devwatch.Snapshot{