wavetermdev/waveterm · error

Error reading request body: %v

Error message

Error reading request body: %v

What it means

handleVDom reads the full request body with io.ReadAll; if that fails, pkg/web/webvdomproto.go:47 returns HTTP 500 with 'Error reading request body: <err>'. The underlying cause (connection reset, body size limit, timeout) is embedded in the message.

Source

Thrown at pkg/web/webvdomproto.go:47

	// Simple UUID validation
	if len(uuid) != 36 {
		http.Error(w, "Invalid UUID format", http.StatusBadRequest)
		return
	}

	// Reconstruct the remaining path
	path := "/" + strings.Join(pathParts[1:], "/")
	if r.URL.RawQuery != "" {
		path += "?" + r.URL.RawQuery
	}

	// Read request body if present
	var body []byte
	var err error
	if r.Body != nil {
		body, err = io.ReadAll(r.Body)
		if err != nil {
			http.Error(w, fmt.Sprintf("Error reading request body: %v", err), http.StatusInternalServerError)
			return
		}
		defer r.Body.Close()
	}

	// Convert headers to map
	headers := make(map[string]string)
	for key, values := range r.Header {
		if len(values) > 0 {
			headers[key] = values[0]
		}
	}

	// Prepare RPC request data
	data := wshrpc.VDomUrlRequestData{
		Method:  r.Method,
		URL:     path,
		Headers: headers,

View on GitHub (pinned to a4447c1563)

Solutions

  1. Inspect the wrapped error in the response body to identify the root cause (unexpected EOF, context canceled, http: request body too large).
  2. Retry the request from a stable connection; for aborted uploads this is usually transient.
  3. Reduce request body size or raise server body limits (http.MaxBytesReader, proxy client_max_body_size).
  4. Check proxy/load-balancer timeout settings so large or slow uploads are not terminated.
  5. Ensure the client completes writing the body before awaiting the response.

Example fix

// before: no limit handling, giant upload dies mid-stream
resp := await fetch("/vdom/"+id+"/file", {method: "POST", body: hugeBlob})

// after: chunk or compress the payload
const compressed = gzipSync(hugeBlob)
resp := await fetch("/vdom/"+id+"/file", {method: "POST", body: compressed, headers: {"Content-Encoding": "gzip"}})
Defensive patterns

Strategy: retry

Validate before calling

// check body size before upload
if (body.length > MAX_BODY_BYTES) throw new Error("payload too large for /vdom endpoint");

Try / catch

const resp = await fetch(url, {method: "POST", body});
if (resp.status === 500 && (await resp.text()).startsWith("Error reading request body")) {
  return retryWithBackoff(() => fetch(url, {method: "POST", body}));
}

Prevention

When it happens

Trigger: The HTTP client disconnects mid-upload, a proxy/middleware truncates or aborts the body, or the server enforces a MaxBytesReader/timeout that trips while streaming the request body.

Common situations: Uploading large request payloads over flaky networks, load balancers with short idle timeouts killing long uploads, clients canceling requests (page navigation/AbortController) before the body finishes sending.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/ed5229e68b95d278. Report an issue: GitHub.