cloudflare/cloudflared · error

scanner reported an error: %w

Error message

scanner reported an error: %w

What it means

Decode reads traceroute output line by line via a bufio.Scanner and returns the parsed hops. If the underlying reader produced an I/O error during scanning (scanner.Err() != nil), Decode wraps it with this message. It indicates the traceroute output stream was interrupted, not that a line was unparseable.

Source

Thrown at diagnostic/network/collector_utils.go:70

		text := scanner.Text()
		if text == "" {
			continue
		}

		hop, err := decodeLine(text)
		if err != nil {
			// This continue is here on the error case because there are lines at the start and end
			// that may not be parsable. (check windows tracert output)
			// The skip is here because aside from the start and end lines the other lines should
			// always be parsable without errors.
			continue
		}

		hops = append(hops, hop)
	}

	if scanner.Err() != nil {
		return nil, fmt.Errorf("scanner reported an error: %w", scanner.Err())
	}

	return hops, nil
}

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Check the raw traceroute output (the collector tees it) for truncation or garbage.
  2. If lines are unusually long, raise the scanner buffer in a fork/patch: scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024).
  3. Verify traceroute completes normally; a crashed process breaks the pipe mid-read.
  4. Retry the diagnostic collection.
Defensive patterns

Strategy: fallback

Validate before calling

// ensure traceroute terminates normally first
cmd := exec.Command("traceroute", "-n", "-m", "15", host)
if err := cmd.Run(); err != nil {
	// traceroute itself fails; decoding will see pipe errors
}

Try / catch

hops, raw, err := network.Collect(ctx, cfg)
if err != nil {
	// raw output tee is still available for manual inspection
	log.Warn().Err(err).Str("raw", raw).Msg("decode failed")
}

Prevention

When it happens

Trigger: The stdout pipe from the traceroute process returns an I/O error while Decode reads it — process killed abruptly breaking the pipe, or read errors on the pipe; also reachable if a scanner buffer limit is exceeded, though that surfaces as bufio.ErrTooLong through Err().

Common situations: Traceroute process crashing mid-output; extremely long output lines exceeding bufio.Scanner's default 64KB token limit; pipe errors under fd pressure.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/f819234dca39159d. Report an issue: GitHub.