• Tashfeen's avatar
    fix(server): error handler crash + missing platforms + per-provider timeout (#7) · 694d75cf
    Tashfeen authored
    * fix(server): guard errorHandler against headers-already-sent
    
    When an LLM completion errors mid-stream, the response is already
    flushing tokens to the client. The handler then unconditionally called
    res.status().json(), throwing ERR_HTTP_HEADERS_SENT and triggering a
    pm2 restart. Short-circuit to Express's default handler once headers
    have been sent so the socket closes cleanly.
    
    * feat(providers): configurable per-provider HTTP timeout
    
    OpenAICompatProvider now accepts an optional timeoutMs constructor
    option (default 15000ms). Cloud APIs respond well within the existing
    default, but locally-hosted OpenAI-compatible inference (llama.cpp,
    vLLM on CPU) can take 30-120s for long prompts and was being aborted
    mid-generation, causing the proxy to mark the key invalid.
    
    * fix(keys): add zhipu, moonshot, minimax to platform allowlist
    
    These three platforms exist in the Platform type union and have
    provider registrations, but were missing from the PLATFORMS array
    in the keys route. Without them, the addKey Zod schema rejects
    requests to add API keys for these providers.
    694d75cf
keys.ts 3.16 KB