{"record":{"id":"41add01dd4a77926","repo":"decolua/9router","slug":"pxpipe-endpoint-failed","errorCode":null,"errorMessage":"PXPIPE ${endpoint} failed","messagePattern":"PXPIPE (.+?) failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/app/(dashboard)/dashboard/token-saver/TokenSaverClient.js","lineNumber":387,"sourceCode":"  }, []);\n\n  const runPxpipeHealth = useCallback(async () => {\n    try {\n      const res = await fetch(\"/api/pxpipe/health\", { method: \"POST\" });\n      setPxpipeHealth(await res.json());\n    } catch (e) {\n      setPxpipeHealth({ healthy: false, checks: [], error: e.message });\n    }\n  }, []);\n\n  const pxpipeAction = useCallback(\n    async (endpoint) => {\n      setPxpipeActionError(\"\");\n      setPxpipeActionLoading(true);\n      try {\n        const res = await fetch(`/api/pxpipe/${endpoint}`, { method: \"POST\" });\n        const data = await res.json().catch(() => ({}));\n        if (!res.ok) throw new Error(data.error || `PXPIPE ${endpoint} failed`);\n        await refreshPxpipeStatus();\n        await runPxpipeHealth();\n      } catch (e) {\n        setPxpipeActionError(e.message);\n      } finally {\n        setPxpipeActionLoading(false);\n      }\n    },\n    [refreshPxpipeStatus, runPxpipeHealth]\n  );\n\n  const handlePxpipeEnabled = (value) => {\n    setPxpipeEnabled(value);\n    patchSetting({ pxpipeEnabled: value });\n  };\n\n  const handlePxpipeMinCharsBlur = () => {\n    const next = Math.max(0, Number(pxpipeMinChars) || 25000);","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/app/(dashboard)/dashboard/token-saver/TokenSaverClient.js#L369-L405","documentation":"TokenSaverClient's pxpipe action runner POSTs to /api/pxpipe/<endpoint> (start, stop, restart, install, stats, health, logs, status). On any non-OK response it throws data.error or the generic 'PXPIPE <endpoint> failed'. The route handlers return 4xx/5xx JSON errors when the underlying pxpipe operation fails.","triggerScenarios":"POST /api/pxpipe/{install|start|stop|restart|health|stats|status|logs} responds with a non-2xx status — e.g. pxpipe not installed, the pxpipe process fails to spawn/stop, or a server-side exception — producing this error in setPxpipeActionError.","commonSituations":"pxpipe CLI not installed before clicking start/restart; spawn failures due to PATH or permissions; pxpipe already stopped when stop is clicked; server-side 500 from an unhandled error in the route.","solutions":["Check the server logs / pxpipe logs endpoint (GET /api/pxpipe/logs) for the underlying failure.","Run the install action (POST /api/pxpipe/install) first — start/restart fail when pxpipe is not installed.","Poll GET /api/pxpipe/status before acting; many actions fail when the proxy is already in the requested state.","Retry the action; transient spawn/health-check races often succeed on a second attempt."],"exampleFix":"// before\nif (!res.ok) throw new Error(data.error || `PXPIPE ${endpoint} failed`);\n// after\nif (!res.ok) throw new Error(data.error || `PXPIPE ${endpoint} failed (HTTP ${res.status}: ${data.code || \"no code\"})`);","handlingStrategy":"try-catch","validationCode":"const status = await fetch(\"/api/pxpipe/status\").then((r) => r.json()).catch(() => null);\nif (!status) throw new Error(\"pxpipe status unavailable — is the server running?\");\nif (action !== \"install\" && !status.installed) throw new Error(\"pxpipe not installed — run install first\");","typeGuard":"const isPxpipeError = (d) => d && typeof d === \"object\" && (typeof d.error === \"string\" || typeof d.code === \"string\");","tryCatchPattern":"try {\n  const res = await fetch(`/api/pxpipe/${endpoint}`, { method: \"POST\" });\n  const data = await res.json().catch(() => ({}));\n  if (!res.ok) throw new Error(data.error || `PXPIPE ${endpoint} failed (HTTP ${res.status})`);\n} catch (e) {\n  setPxpipeActionError(e.message);\n  const logs = await fetch(\"/api/pxpipe/logs\").then((r) => r.json()).catch(() => null);\n  if (logs) console.warn(\"pxpipe logs:\", logs);\n}","preventionTips":["Install pxpipe before invoking start/stop/restart actions.","Poll status first to avoid acting on an already-satisfied state.","Include HTTP status in user-facing messages for diagnosability."],"tags":["proxy","http-error","ui-error"],"backgroundTag":"http-5xx-server-error","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}