Repository navigation
Description
Before opening, please confirm
- I have searched for duplicate or closed issues.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Which package(s) are affected?
Core
Describe the bug
Every ApiNamespace method runs behind API Gateway and Lambda once deployed, so it inherits their limits. The local dev server enforces none of them except a 10 MiB request cap:
| Call | Local | Deployed |
|---|---|---|
| a method that takes 28 s or more | ok (no failure up to 40 s) | 504 HandlerTimeoutError from 28 s |
| a method whose result is over 6 MB | ok (no failure up to 8 MiB) | 502 from API Gateway |
| a request body between 6 MB and 10 MiB | ok | 413 from API Gateway |
| a request body over 10 MiB | 413 PayloadTooLarge |
413 from API Gateway |
The Lambda handler already races the handler against a deadline just under API Gateway's 29 s (HandlerTimeoutError, 504), but the dev server has no equivalent, so a slow report, export or model call that works in npm run dev times out in production. The same goes for large results: the 6 MB Lambda response limit only shows up after deploy (and, because of the client bug filed alongside this one, shows up as undefined rather than an error).
Expected behavior
The dev server applies the deployed limits to RPC calls: the same handler deadline (returning the same 504 HandlerTimeoutError envelope), a 6 MB request and response limit (or a clear warning when a response exceeds it), so the failure appears during development.
Reproduction steps
export const api = new ApiNamespace(scope, 'api', () => ({
async slow() { await new Promise((r) => setTimeout(r, 30_000)); return 'done'; },
async big() { return 'a'.repeat(7 * 1024 * 1024); },
async upload(body: string) { return body.length; },
}));npm run dev:api.slow()returns'done',api.big()returns the string,api.upload('a'.repeat(7 * 1024 * 1024))returns the length.- Deploy and repeat:
slow()fails with 504HandlerTimeoutError,big()gets a 502,upload()gets a 413.
Environment
@aws-blocks/*0.8.0 (mainat 34e758c)- Local:
npm run devdev server, Node 22, macOS - Deployed: a sandbox stack in us-east-1
Additional context
- Limits: https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html (REST API integration timeout 29 s, payload 10 MB), https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html (6 MB synchronous payload).
- Likely location: the RPC path in
packages/core/src/scripts/dev-server.ts(around line 1471,parseRpcRequestis the only size check, usingMAX_RPC_BODY_BYTES= 10 MiB frompackages/core/src/rpc.ts); the deployed deadline lives inpackages/core/src/lambda-handler.ts(computeHttpDeadlineMs,HandlerTimeoutError) and could be shared. - Related: Right-size production defaults: API handler timeout ≤29s + smaller memory, alarm subscriber prompt, make the dedicated KMS key opt-in #767 (API handler timeout default vs the 29 s cap), core: local dev server responses differ from the deployed API for 404s, CORS preflight and caching headers #1196 (other dev-server response differences).
Activity