{"record":{"id":"ddc49aaafdbbcb8f","repo":"openfaas/faas","slug":"error-queuing-request-s","errorCode":null,"errorMessage":"Error queuing request: %s","messagePattern":"Error queuing request: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"gateway/handlers/queue_proxy.go","lineNumber":61,"sourceCode":"\t\t}\n\n\t\tvars := mux.Vars(r)\n\t\tname := vars[\"name\"]\n\n\t\treq := &ftypes.QueueRequest{\n\t\t\tFunction:    name,\n\t\t\tBody:        body,\n\t\t\tMethod:      r.Method,\n\t\t\tQueryString: r.URL.RawQuery,\n\t\t\tPath:        pathTransformer.Transform(r),\n\t\t\tHeader:      r.Header,\n\t\t\tHost:        r.Host,\n\t\t\tCallbackURL: callbackURL,\n\t\t}\n\n\t\tif err = queuer.Queue(req); err != nil {\n\t\t\tlog.Printf(\"Error queuing request: %v\", err)\n\t\t\thttp.Error(w, fmt.Sprintf(\"Error queuing request: %s\", err.Error()),\n\t\t\t\thttp.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(http.StatusAccepted)\n\t}\n}\n\nfunc getCallbackURLHeader(header http.Header) (*url.URL, error) {\n\tvalue := header.Get(\"X-Callback-Url\")\n\tvar callbackURL *url.URL\n\n\tif len(value) > 0 {\n\t\turlVal, err := url.Parse(value)\n\t\tif err != nil {\n\t\t\treturn callbackURL, err\n\t\t}\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/openfaas/faas/blob/8d803bf9e2655aec6a60fd0e25b392839f96af95/gateway/handlers/queue_proxy.go#L43-L79","documentation":"After building the QueueRequest, MakeQueuedProxy publishes it through the configured RequestQueuer (nats-queue in the standard OpenFaaS stack). A publish failure returns 500 with 'Error queuing request: <err>'. Only a successful publish yields 202 Accepted, so this error means the async invocation was not accepted at all.","triggerScenarios":"POST /async-function/{name} while the queue backend is unavailable: nats-streaming pod down or not ready, wrong NATS address or port (4222), the request body exceeding NATS max_payload (default 1MB), or the queue connector crashed.","commonSituations":"nats-streaming StatefulSet not running or evicted; chart installed without queue mode; NATS max_payload smaller than the async body; resource limits killing the streaming server.","solutions":["Check queue health: kubectl get pods -n openfaas and confirm the nats pod is Running/Ready","Verify connectivity to NATS port 4222 from the cluster (nc -z nats.openfaas.svc 4222)","Reduce the async payload below the NATS max_payload limit or raise the limit","Read the embedded error text ('nats: connection closed', 'payload too large') — it names the exact failure","Restart the queue connector if its NATS connection is stale"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# preflight: NATS reachable before firing async requests\nnc -z nats.openfaas 4222 || echo 'NATS down: /async-function/* calls will fail'","typeGuard":null,"tryCatchPattern":"resp, err := client.Post(asyncURL, contentType, body)\nif err != nil || resp.StatusCode == http.StatusInternalServerError {\n    // queue backend unavailable: wait, then re-enqueue the whole job\n    time.Sleep(backoff)\n    continue\n}","preventionTips":["Monitor the nats-streaming pod and alert before it degrades","Keep async payloads under the NATS max_payload (default 1MB)","Treat 202 Accepted as the only success signal — anything else means the job was not queued","Persist jobs locally so failed enqueues can be replayed"],"tags":["async","nats","queue","kubernetes","messaging"],"backgroundTag":null,"analyzedSha":"8d803bf9e2655aec6a60fd0e25b392839f96af95","analyzedAt":"2026-08-16T00:12:29.759Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}