feat(tts): add TTS_UPSTREAM_TIMEOUT_MS for configurable request timeout
This commit is contained in:
parent
4505684108
commit
f9237f9270
7 changed files with 47 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ API_KEY=api_key_optional
|
||||||
# TTS_RETRY_INITIAL_MS=250
|
# TTS_RETRY_INITIAL_MS=250
|
||||||
# TTS_RETRY_MAX_MS=2000
|
# TTS_RETRY_MAX_MS=2000
|
||||||
# TTS_RETRY_BACKOFF=2
|
# TTS_RETRY_BACKOFF=2
|
||||||
|
# TTS_UPSTREAM_TIMEOUT_MS=285000 # 285 seconds
|
||||||
|
|
||||||
# (Optional) Enable TTS character rate limiting (default is `false`)
|
# (Optional) Enable TTS character rate limiting (default is `false`)
|
||||||
# TTS_ENABLE_RATE_LIMIT=true
|
# TTS_ENABLE_RATE_LIMIT=true
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ This is the single reference page for OpenReader environment variables.
|
||||||
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
||||||
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
||||||
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
||||||
|
| `TTS_UPSTREAM_TIMEOUT_MS` | TTS request timeout | `285000` | Set max upstream TTS request duration before fail-fast |
|
||||||
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
||||||
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
||||||
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
||||||
|
|
@ -113,6 +114,14 @@ Exponential backoff multiplier between retries.
|
||||||
|
|
||||||
- Default: `2`
|
- Default: `2`
|
||||||
|
|
||||||
|
### TTS_UPSTREAM_TIMEOUT_MS
|
||||||
|
|
||||||
|
Maximum upstream TTS request timeout in milliseconds.
|
||||||
|
|
||||||
|
- Default: `285000` (285 seconds)
|
||||||
|
- Applies to outbound provider calls from server routes using shared TTS generation
|
||||||
|
- Increase for slower providers/models; decrease to fail fast and surface retryable errors sooner
|
||||||
|
|
||||||
### TTS_ENABLE_RATE_LIMIT
|
### TTS_ENABLE_RATE_LIMIT
|
||||||
|
|
||||||
Controls TTS character rate limiting in the TTS API.
|
Controls TTS character rate limiting in the TTS API.
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ This is the single reference page for OpenReader environment variables.
|
||||||
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
||||||
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
||||||
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
||||||
|
| `TTS_UPSTREAM_TIMEOUT_MS` | TTS request timeout | `285000` | Set max upstream TTS request duration before fail-fast |
|
||||||
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
||||||
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
||||||
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
||||||
|
|
@ -110,6 +111,14 @@ Exponential backoff multiplier between retries.
|
||||||
|
|
||||||
- Default: `2`
|
- Default: `2`
|
||||||
|
|
||||||
|
### TTS_UPSTREAM_TIMEOUT_MS
|
||||||
|
|
||||||
|
Maximum upstream TTS request timeout in milliseconds.
|
||||||
|
|
||||||
|
- Default: `285000` (285 seconds)
|
||||||
|
- Applies to outbound provider calls from server routes using shared TTS generation
|
||||||
|
- Increase for slower providers/models; decrease to fail fast and surface retryable errors sooner
|
||||||
|
|
||||||
### TTS_ENABLE_RATE_LIMIT
|
### TTS_ENABLE_RATE_LIMIT
|
||||||
|
|
||||||
Controls TTS character rate limiting in the TTS API.
|
Controls TTS character rate limiting in the TTS API.
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ This is the single reference page for OpenReader environment variables.
|
||||||
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
||||||
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
||||||
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
||||||
|
| `TTS_UPSTREAM_TIMEOUT_MS` | TTS request timeout | `285000` | Set max upstream TTS request duration before fail-fast |
|
||||||
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
||||||
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
||||||
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
||||||
|
|
@ -110,6 +111,14 @@ Exponential backoff multiplier between retries.
|
||||||
|
|
||||||
- Default: `2`
|
- Default: `2`
|
||||||
|
|
||||||
|
### TTS_UPSTREAM_TIMEOUT_MS
|
||||||
|
|
||||||
|
Maximum upstream TTS request timeout in milliseconds.
|
||||||
|
|
||||||
|
- Default: `285000` (285 seconds)
|
||||||
|
- Applies to outbound provider calls from server routes using shared TTS generation
|
||||||
|
- Increase for slower providers/models; decrease to fail fast and surface retryable errors sooner
|
||||||
|
|
||||||
### TTS_ENABLE_RATE_LIMIT
|
### TTS_ENABLE_RATE_LIMIT
|
||||||
|
|
||||||
Controls TTS character rate limiting in the TTS API.
|
Controls TTS character rate limiting in the TTS API.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ This is the single reference page for OpenReader environment variables.
|
||||||
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
||||||
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
||||||
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
||||||
|
| `TTS_UPSTREAM_TIMEOUT_MS` | TTS request timeout | `285000` | Set max upstream TTS request duration before fail-fast |
|
||||||
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
||||||
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
||||||
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
||||||
|
|
@ -113,6 +114,14 @@ Exponential backoff multiplier between retries.
|
||||||
|
|
||||||
- Default: `2`
|
- Default: `2`
|
||||||
|
|
||||||
|
### TTS_UPSTREAM_TIMEOUT_MS
|
||||||
|
|
||||||
|
Maximum upstream TTS request timeout in milliseconds.
|
||||||
|
|
||||||
|
- Default: `285000` (285 seconds)
|
||||||
|
- Applies to outbound provider calls from server routes using shared TTS generation
|
||||||
|
- Increase for slower providers/models; decrease to fail fast and surface retryable errors sooner
|
||||||
|
|
||||||
### TTS_ENABLE_RATE_LIMIT
|
### TTS_ENABLE_RATE_LIMIT
|
||||||
|
|
||||||
Controls TTS character rate limiting in the TTS API.
|
Controls TTS character rate limiting in the TTS API.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ This is the single reference page for OpenReader environment variables.
|
||||||
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
| `TTS_RETRY_INITIAL_MS` | TTS retry | `250` | Tune initial retry delay |
|
||||||
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
| `TTS_RETRY_MAX_MS` | TTS retry | `2000` | Tune max retry delay |
|
||||||
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
| `TTS_RETRY_BACKOFF` | TTS retry | `2` | Tune exponential backoff factor |
|
||||||
|
| `TTS_UPSTREAM_TIMEOUT_MS` | TTS request timeout | `285000` | Set max upstream TTS request duration before fail-fast |
|
||||||
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
| `TTS_ENABLE_RATE_LIMIT` | Rate limiting | `false` | Set `true` to enable TTS per-user/IP daily character limits |
|
||||||
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
| `TTS_DAILY_LIMIT_ANONYMOUS` | Rate limiting | `50000` | Override anonymous per-user daily character limit |
|
||||||
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
| `TTS_DAILY_LIMIT_AUTHENTICATED` | Rate limiting | `500000` | Override authenticated per-user daily character limit |
|
||||||
|
|
@ -113,6 +114,14 @@ Exponential backoff multiplier between retries.
|
||||||
|
|
||||||
- Default: `2`
|
- Default: `2`
|
||||||
|
|
||||||
|
### TTS_UPSTREAM_TIMEOUT_MS
|
||||||
|
|
||||||
|
Maximum upstream TTS request timeout in milliseconds.
|
||||||
|
|
||||||
|
- Default: `285000` (285 seconds)
|
||||||
|
- Applies to outbound provider calls from server routes using shared TTS generation
|
||||||
|
- Increase for slower providers/models; decrease to fail fast and surface retryable errors sooner
|
||||||
|
|
||||||
### TTS_ENABLE_RATE_LIMIT
|
### TTS_ENABLE_RATE_LIMIT
|
||||||
|
|
||||||
Controls TTS character rate limiting in the TTS API.
|
Controls TTS character rate limiting in the TTS API.
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ async function runProviderRequest(request: ResolvedServerTTSRequest, signal: Abo
|
||||||
apiKey: request.apiKey,
|
apiKey: request.apiKey,
|
||||||
baseURL: request.baseUrl,
|
baseURL: request.baseUrl,
|
||||||
maxRetries: 0,
|
maxRetries: 0,
|
||||||
timeout: Number(process.env.TTS_UPSTREAM_TIMEOUT_MS ?? 45_000),
|
timeout: Number(process.env.TTS_UPSTREAM_TIMEOUT_MS ?? 285_000),
|
||||||
});
|
});
|
||||||
|
|
||||||
const createParams: ExtendedSpeechParams = {
|
const createParams: ExtendedSpeechParams = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue