mirror of
https://github.com/chenyme/grok2api.git
synced 2026-12-06 00:01:05 +00:00
Two issues in the voice/STT WebSocket proxy: 1. The established proxy never watched c.Request.Context().Done(), so server.requestTimeout had no effect on a quiet, already-admitted session: the account lease, concurrency slot, and upstream connection stayed open past the configured deadline until a transport error occurred on either side. Added a watcher that closes the session once the request context is canceled, extracted as watchRequestTimeout so it is unit-testable without a real WebSocket upgrade. 2. STT billing was gated on the downstream client closing cleanly (successful == ErrorCode == ""), even though the cost is already incurred the moment the upstream sends a confirmed transcript.done duration. A client that received a complete transcription and then disconnected abnormally left EstimatedCostInUSDTicks at zero, understating usage against the key's billing limit. Billing is now keyed on having a confirmed duration, not on how the transport ended.