/Knowledge/sources/honojs__hono/llms-full/timeout-middleware-usage--part-02--8639b987d502.md

Timeout Middleware: Usage (part 02) - hono-docs

Timeout Middleware: Usage (part 02) Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt usage Summary ts i...

Timeout Middleware: Usage (part 02)

Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#usage

Summary

```ts import { HTTPException } from 'hono/http-exception' // Custom exception factory function const customTimeoutException = (context) => new HTTPException(408, { message: `Request timeout after waiting ${context.req.headers.get( 'Durat...

Content

import { HTTPException } from 'hono/http-exception'

// Custom exception factory function
const customTimeoutException = (context) =>
  new HTTPException(408, {
    message: `Request timeout after waiting ${context.req.headers.get(
      'Duration'
    )} seconds. Please try again later.`,
  })

// for Static Exception Message
// const customTimeoutException = new HTTPException(408, {
//   message: 'Operation timed out. Please try again later.'
// });

// Applying a 1-minute timeout with a custom exception
app.use('/api/long-process', timeout(60000, customTimeoutException))

app.get('/api/long-process', async (c) => {
  // Simulate a long process
  await new Promise((resolve) => setTimeout(resolve, 61000))
  return c.json({ data: 'This usually takes longer' })
})

Metadata

{
  "chunk_index": 1,
  "citation": "https://hono.dev/llms-full.txt#usage",
  "coverage_role": "overview",
  "qualified_title": "Hono / llms-full / Timeout Middleware > Usage (2)",
  "retrieved_at": "2026-07-02T05:51:01Z",
  "section_index": 349,
  "source_id": "/honojs/hono",
  "source_type": "llms_full",
  "target_label": "llms-full",
  "title": "Timeout Middleware: Usage (part 02)",
  "upstream_url": "https://hono.dev/llms-full.txt",
  "version": "2026"
}
Kinic Wiki
Loading knowledge node
Details

Identity

database
db_23dhmsxlhukv
database_id
db_23dhmsxlhukv
path
/Knowledge/sources/honojs__hono/llms-full/timeout-middleware-usage--part-02--8639b987d502.md
kind
directory
role
markdown_note
children
0

Metadata

created_at
virtual
updated_at
virtual
etag
virtual
metadata_json
{}

Lint Hints

No lightweight warnings.

Outgoing Links

No outgoing links indexed.

Incoming Links

Select a file node to inspect backlinks.

Raw Source

No raw source path inferred.