Add global 30s request timeout middleware #466

Open
pook wants to merge 50 commits from feat/global-request-timeout into main
Owner

Summary

  • Adds a server-level request timeout middleware that aborts any HTTP request exceeding 30 seconds with a 504 Gateway Timeout response
  • Uses Hono built-in timeout middleware with a custom exception factory that logs method, path, and duration
  • Applied as the outermost global middleware covering all routes including billing, generate, auth, and health

Files changed

  • packages/api/src/middleware/request-timeout.ts — new timeout middleware (17 LOC)
  • packages/api/src/index.ts — import and wire as first middleware
  • packages/api/tests/unit/request-timeout.test.ts — 3 unit tests

Test plan

  • Requests within 30s return normally (200)
  • Requests exceeding timeout get 504 with JSON error body
  • All route patterns covered
  • Type check passes
  • 185 existing tests still pass
## Summary - Adds a server-level request timeout middleware that aborts any HTTP request exceeding 30 seconds with a 504 Gateway Timeout response - Uses Hono built-in `timeout` middleware with a custom exception factory that logs method, path, and duration - Applied as the outermost global middleware covering all routes including billing, generate, auth, and health ## Files changed - `packages/api/src/middleware/request-timeout.ts` — new timeout middleware (17 LOC) - `packages/api/src/index.ts` — import and wire as first middleware - `packages/api/tests/unit/request-timeout.test.ts` — 3 unit tests ## Test plan - [x] Requests within 30s return normally (200) - [x] Requests exceeding timeout get 504 with JSON error body - [x] All route patterns covered - [x] Type check passes - [x] 185 existing tests still pass
Add global 30s request timeout middleware for all routes
Some checks are pending
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Waiting to run
509dcf10d3
Uses Hono's built-in timeout middleware to abort any HTTP request
exceeding 30 seconds with a 504 Gateway Timeout response. Applied as
the outermost middleware so it covers all routes including billing,
generate, auth, and health endpoints. Timeout events are logged with
the request method and path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: issue #464 add-a-server-level-request-timeout-middl (agent task liancebot464)
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
40e13cfd51
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
This pull request has changes conflicting with the target branch.
  • .forgejo/workflows/ci.yml
  • bun.lock
  • package.json
  • packages/api/src/db/schema.ts
  • packages/api/src/index.ts
  • packages/api/src/middleware/rate-limit.ts
  • packages/api/src/middleware/security-headers.ts
  • packages/api/src/routes/generate-tos.ts
  • packages/api/src/routes/generate.ts
  • packages/api/src/routes/health.ts
  • packages/api/src/routes/questionnaire.ts
  • packages/api/src/services/document-generator.ts
  • packages/api/src/services/llm.ts
  • packages/api/src/templates/index.ts
  • packages/api/tsconfig.json
  • packages/shared/src/types.ts
  • packages/web/src/app/questionnaire/page.tsx
  • packages/web/src/components/documents/DocumentList.tsx
  • packages/web/src/components/questionnaire/ReviewStep.tsx
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/global-request-timeout:feat/global-request-timeout
git switch feat/global-request-timeout
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!466
No description provided.