openfaas/faas · error

err.Error()

Error message

err.Error()

What it means

MakeQueuedProxy, which serves POST /async-function/{name}, buffers the whole request body with io.ReadAll before enqueueing. If the read itself fails, the raw Go error text is echoed to the client with status 400. A read failure means the transfer was broken or malformed — the queue has not been contacted yet at this point.

Source

Thrown at gateway/handlers/queue_proxy.go:34

	"github.com/gorilla/mux"
	ftypes "github.com/openfaas/faas-provider/types"
	"github.com/openfaas/faas/gateway/metrics"
	"github.com/openfaas/faas/gateway/pkg/middleware"

	"github.com/openfaas/faas/gateway/scaling"
)

// MakeQueuedProxy accepts work onto a queue
func MakeQueuedProxy(metrics metrics.MetricOptions, queuer ftypes.RequestQueuer, pathTransformer middleware.URLPathTransformer, defaultNS string, functionQuery scaling.FunctionQuery) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var body []byte
		if r.Body != nil {
			defer r.Body.Close()

			var err error
			body, err = io.ReadAll(r.Body)
			if err != nil {
				http.Error(w, err.Error(), http.StatusBadRequest)
				return
			}
		}

		callbackURL, err := getCallbackURLHeader(r.Header)
		if err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}

		vars := mux.Vars(r)
		name := vars["name"]

		req := &ftypes.QueueRequest{
			Function:    name,
			Body:        body,
			Method:      r.Method,
			QueryString: r.URL.RawQuery,

View on GitHub (pinned to 8d803bf9e2)

Solutions

  1. Retry the invocation — mid-body disconnects are usually transient
  2. Reduce the payload size; async bodies are fully buffered and additionally limited by the queue backend
  3. Raise body-size/buffering limits on any ingress proxy in front of the gateway
  4. Use a standard HTTP client library so chunked encoding and headers are well-formed
  5. Inspect the echoed error text ('unexpected EOF', 'malformed HTTP chunked encoding') to identify the failing layer
Defensive patterns

Strategy: retry

Try / catch

resp, err := client.Post(asyncURL, contentType, bytes.NewReader(body))
if err != nil || resp.StatusCode == http.StatusBadRequest {
    // body transfer was interrupted: replay the buffered body after backoff
    time.Sleep(backoff)
    continue
}

Prevention

When it happens

Trigger: Client disconnects or times out mid-upload; malformed chunked transfer encoding; an intermediary (nginx, Traefik, Istio) resets the connection when a body-size or buffering limit is exceeded; keep-alive connection races.

Common situations: Large async payloads exceeding proxy limits (nginx client_max_body_size, Traefik body limits); SDKs with aggressive client timeouts aborting during upload; flaky client networks; custom clients hand-rolling chunked encoding.

Related errors


AI-assisted analysis of openfaas/faas@8d803bf9e2 (2026-08-16). Data as JSON: /api/errors/6d67949101efadf1. Report an issue: GitHub.