juanfont/headscale · error

%s reading confirm response: %w

Error message

%s reading confirm response: %w

What it means

`io.ReadAll(confirmResp.Body)` failed while draining the confirm POST response. The request succeeded at the transport level but the body stream broke mid-read — connection reset, content-length mismatch, or the container died while streaming.

Source

Thrown at integration/scenario.go:1327

	ctx := context.Background()

	req, err := http.NewRequestWithContext(ctx, http.MethodPost, confirmURL.String(), strings.NewReader(formData.Encode()))
	if err != nil {
		return "", nil, fmt.Errorf("%s creating confirm request: %w", hostname, err)
	}

	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	confirmResp, err := hc.Do(req)
	if err != nil {
		return "", nil, fmt.Errorf("%s sending confirm request: %w", hostname, err)
	}
	defer confirmResp.Body.Close()

	confirmBytes, err := io.ReadAll(confirmResp.Body)
	if err != nil {
		return "", nil, fmt.Errorf("%s reading confirm response: %w", hostname, err)
	}

	if confirmResp.StatusCode != http.StatusOK {
		return string(confirmBytes), nil, fmt.Errorf( //nolint:err113
			"%s confirm returned status %d: %s",
			hostname, confirmResp.StatusCode, string(confirmBytes),
		)
	}

	return string(confirmBytes), nil, nil
}

var errParseAuthPage = errors.New("parsing auth page")

func (s *Scenario) runHeadscaleRegister(userStr string, body string) error {
	// see api.go HTML template
	codeSep := strings.Split(body, "</code>")
	if len(codeSep) != 2 {

View on GitHub (pinned to 565fd254d0)

Solutions

  1. Check headscale container logs for a panic or OOM kill at the timestamp of the failure.
  2. Ensure the scenario does not tear down the network/containers before registration completes.
  3. Retry the registration flow; mid-body resets in containerized tests are frequently flakes.
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: The headscale server closes the connection partway through the response body: container OOM-killed or restarted mid-response, proxy in front of headscale truncates, or keep-alive race at test teardown.

Common situations: Test tears down containers while an in-flight response is being read; headscale panics during confirm handling; Docker network removed mid-test.

Related errors


AI-assisted analysis of juanfont/headscale@565fd254d0 (2026-08-15). Data as JSON: /api/errors/53bd16c47828c113. Report an issue: GitHub.