Skip to content

Commit 996428d

Browse files
committed
fix: increase default render timeout to 15s
Covers browser renderer which can take longer than 10s.
1 parent 0972cd7 commit 996428d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

docs/content/3.guides/13.security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ For sites that need a mix of static and dynamic images, you can prerender specif
4343

4444
Every request has its `width` and `height` clamped to `maxDimension` (default `2048` pixels). The Takumi renderer's `devicePixelRatio` is capped to `maxDpr` (default `2`).
4545

46-
If a render exceeds `renderTimeout` (default `10000ms`), it is aborted and the server returns a `408` status.
46+
If a render exceeds `renderTimeout` (default `15000ms`), it is aborted and the server returns a `408` status.
4747

4848
These are all enabled by default. You only need to configure them if you want different limits.
4949

@@ -53,7 +53,7 @@ export default defineNuxtConfig({
5353
security: {
5454
maxDimension: 2048,
5555
maxDpr: 2,
56-
renderTimeout: 10000,
56+
renderTimeout: 15000,
5757
}
5858
}
5959
})

docs/content/4.api/3.config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Security limits for image generation. See the [Security Guide](/docs/og-image/gu
182182

183183
- **`maxDimension`**: Maximum width or height in pixels. Default `2048`.
184184
- **`maxDpr`**: Maximum device pixel ratio (Takumi renderer). Default `2`.
185-
- **`renderTimeout`**: Milliseconds before the render is aborted with a `408` response. Default `10000`.
185+
- **`renderTimeout`**: Milliseconds before the render is aborted with a `408` response. Default `15000`.
186186
- **`maxQueryParamSize`**: Maximum query string length (in characters) for runtime requests. Returns `400` when exceeded. Default `null` (no limit).
187187
- **`restrictRuntimeImagesToOrigin`**: Restrict runtime image generation to requests whose `Host` header matches allowed hosts. Default `false`. See the [Security Guide](/docs/og-image/guides/security#restrict-runtime-images-to-origin) for details.
188188

@@ -192,7 +192,7 @@ export default defineNuxtConfig({
192192
security: {
193193
maxDimension: 2048,
194194
maxDpr: 2,
195-
renderTimeout: 10000,
195+
renderTimeout: 15000,
196196
restrictRuntimeImagesToOrigin: true, // lock to site config URL host
197197
// or: ['https://cdn.example.com'] // allow additional hosts
198198
}

src/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export interface ModuleOptions {
204204
maxDimension?: number
205205
/** Maximum device pixel ratio (takumi renderer). @default 2 */
206206
maxDpr?: number
207-
/** Render timeout in milliseconds. Returns 408 on timeout. @default 10000 */
207+
/** Render timeout in milliseconds. Returns 408 on timeout. @default 15000 */
208208
renderTimeout?: number
209209
/**
210210
* Maximum allowed length (in characters) for the query string on runtime OG image requests.
@@ -1412,7 +1412,7 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`
14121412
security: {
14131413
maxDimension: config.security?.maxDimension ?? 2048,
14141414
maxDpr: config.security?.maxDpr ?? 2,
1415-
renderTimeout: config.security?.renderTimeout ?? 10_000,
1415+
renderTimeout: config.security?.renderTimeout ?? 15_000,
14161416
maxQueryParamSize: config.security?.maxQueryParamSize ?? null,
14171417
restrictRuntimeImagesToOrigin: config.security?.restrictRuntimeImagesToOrigin === true
14181418
? []

src/runtime/server/util/eventHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export async function imageEventHandler(e: H3Event) {
121121
let image: H3Error | BufferSource | Buffer | Uint8Array | false | void = cacheApi.cachedItem
122122
if (!image) {
123123
const { security } = useOgImageRuntimeConfig()
124-
const timeout = security?.renderTimeout || 10_000
124+
const timeout = security?.renderTimeout || 15_000
125125
image = await Promise.race([
126126
renderer.createImage(ctx),
127127
new Promise<never>((_, reject) =>

0 commit comments

Comments
 (0)