Skip to content

Commit

Permalink
Set the Vercel serverless max duration as env variable. Fixes #468
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Mar 29, 2024
1 parent 7fa5947 commit d17a980
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
5 changes: 4 additions & 1 deletion app/api/trpc-node/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const handlerNodeRoutes = (req: Request) =>
});

export const runtime = 'nodejs';

// the Browsing module has a timeout of ~10s, so we increase 15 (default) -> 25
// noinspection JSUnusedGlobalSymbols
export const maxDuration = 25; // the Browsing module has a timeout of ~10s, so we increase 15 (default) -> 25
export const maxDuration = process.env.VERCEL_SERVERLESS_MAX_DURATION ? parseInt(process.env.VERCEL_SERVERLESS_MAX_DURATION, 10) : undefined;
export const dynamic = 'force-dynamic';

export { handlerNodeRoutes as GET, handlerNodeRoutes as POST };
42 changes: 23 additions & 19 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ GOOGLE_CSE_ID=
# Browse
PUPPETEER_WSS_ENDPOINT=

# Backend Analytics
# Backend: Analytics
BACKEND_ANALYTICS=

# Backend HTTP Basic Authentication (see `deploy-authentication.md` for turning on authentication)
# Backend: HTTP Basic Authentication (see `deploy-authentication.md` for turning on authentication)
HTTP_BASIC_AUTH_USERNAME=
HTTP_BASIC_AUTH_PASSWORD=

# Backend: Deployment-specific
VERCEL_SERVERLESS_MAX_DURATION=

# Frontend variables
NEXT_PUBLIC_GA4_MEASUREMENT_ID=
NEXT_PUBLIC_PLANTUML_SERVER_URL=
Expand Down Expand Up @@ -115,23 +118,24 @@ It is currently supported for:

Enable the app to Talk, Draw, and Google things up.

| Variable | Description |
|:---------------------------|:------------------------------------------------------------------------------------------------------------------------|
| **Text-To-Speech** | [ElevenLabs](https://elevenlabs.io/) is a high quality speech synthesis service |
| `ELEVENLABS_API_KEY` | ElevenLabs API Key - used for calls, etc. |
| `ELEVENLABS_API_HOST` | Custom host for ElevenLabs |
| `ELEVENLABS_VOICE_ID` | Default voice ID for ElevenLabs |
| **Text-To-Image** | [Prodia](https://prodia.com/) is a reliable image generation service |
| `PRODIA_API_KEY` | Prodia API Key - used with '/imagine ...' |
| **Google Custom Search** | [Google Programmable Search Engine](https://programmablesearchengine.google.com/about/) produces links to pages |
| `GOOGLE_CLOUD_API_KEY` | Google Cloud API Key, used with the '/react' command - [Link to GCP](https://console.cloud.google.com/apis/credentials) |
| `GOOGLE_CSE_ID` | Google Custom/Programmable Search Engine ID - [Link to PSE](https://programmablesearchengine.google.com/) |
| **Browse** | |
| `PUPPETEER_WSS_ENDPOINT` | Puppeteer WebSocket endpoint - used for browsing (pade downloadeing), etc. |
| **Backend** | |
| `BACKEND_ANALYTICS` | Semicolon-separated list of analytics flags (see backend.analytics.ts). Flags: `domain` logs the responding domain. |
| `HTTP_BASIC_AUTH_USERNAME` | See the [Authentication](deploy-authentication.md) guide. Username for HTTP Basic Authentication. |
| `HTTP_BASIC_AUTH_PASSWORD` | Password for HTTP Basic Authentication. |
| Variable | Description |
|:---------------------------------|:--------------------------------------------------------------------------------------------------------------------------------|
| **Text-To-Speech** | [ElevenLabs](https://elevenlabs.io/) is a high quality speech synthesis service |
| `ELEVENLABS_API_KEY` | ElevenLabs API Key - used for calls, etc. |
| `ELEVENLABS_API_HOST` | Custom host for ElevenLabs |
| `ELEVENLABS_VOICE_ID` | Default voice ID for ElevenLabs |
| **Text-To-Image** | [Prodia](https://prodia.com/) is a reliable image generation service |
| `PRODIA_API_KEY` | Prodia API Key - used with '/imagine ...' |
| **Google Custom Search** | [Google Programmable Search Engine](https://programmablesearchengine.google.com/about/) produces links to pages |
| `GOOGLE_CLOUD_API_KEY` | Google Cloud API Key, used with the '/react' command - [Link to GCP](https://console.cloud.google.com/apis/credentials) |
| `GOOGLE_CSE_ID` | Google Custom/Programmable Search Engine ID - [Link to PSE](https://programmablesearchengine.google.com/) |
| **Browse** | |
| `PUPPETEER_WSS_ENDPOINT` | Puppeteer WebSocket endpoint - used for browsing (pade downloadeing), etc. |
| **Backend** | |
| `BACKEND_ANALYTICS` | Semicolon-separated list of analytics flags (see backend.analytics.ts). Flags: `domain` logs the responding domain. |
| `HTTP_BASIC_AUTH_USERNAME` | See the [Authentication](deploy-authentication.md) guide. Username for HTTP Basic Authentication. |
| `HTTP_BASIC_AUTH_PASSWORD` | Password for HTTP Basic Authentication. |
| `VERCEL_SERVERLESS_MAX_DURATION` | Optionally changes the maximum duration (in seconds) for serverless (not edge) functions on Vercel. See your plan for defaults. |

### Frontend Variables

Expand Down
3 changes: 3 additions & 0 deletions src/server/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export const env = createEnv({
HTTP_BASIC_AUTH_USERNAME: z.string().optional(),
HTTP_BASIC_AUTH_PASSWORD: z.string().optional(),

// Backend: Deployment-specific
VERCEL_SERVERLESS_MAX_DURATION: z.string().optional(),

// Build-time configuration
BIG_AGI_BUILD: z.enum(['standalone', 'static']).optional(),

Expand Down

0 comments on commit d17a980

Please sign in to comment.