AWS Lambda error tracking your coding agent can read
Lambda freezes the execution environment as soon as your handler returns or throws, so an error reporter that sends in the background can lose the event. With Runheed you catch the error, record it with the request id and rethrow, so Lambda still marks the invocation as failed. In Node.js you await flush() first, because the Node SDK batches events; the Python SDK sends before capture_exception returns. Your coding agent reads the error and the stack trace over MCP.
Set it up
1.Add the SDK to the function's dependencies (Node.js or Python) and set RUNHEED_DSN under Configuration > Environment variables in the Lambda console, or in your SAM, CDK, Serverless or Terraform config.
terminalbashnpm install https://runheed.com/dl/runheed-0.1.0.tgz # or, for a Python function packaged as a zip: pip install https://runheed.com/dl/runheed-0.1.0-py3-none-any.whl -t ./package2.Node.js: initialize outside the handler (once per cold start), then report, flush and rethrow.
index.mjsjavascriptimport runheed from 'runheed'; runheed.init({ dsn: process.env.RUNHEED_DSN, environment: 'production' }); export const handler = async (event, context) => { try { // ...your code return { statusCode: 200, body: JSON.stringify({ ok: true }) }; } catch (err) { runheed.captureException(err, { awsRequestId: context.awsRequestId, functionName: context.functionName }); await runheed.flush(); throw err; } };3.Python: the SDK sends the event before capture_exception returns, so there is nothing to flush. Report and re-raise.
lambda_function.pypythonimport os import runheed runheed.init(dsn=os.environ["RUNHEED_DSN"], environment="production") def lambda_handler(event, context): try: # ...your code return {"statusCode": 200, "body": "ok"} except Exception as e: runheed.capture_exception(e, extra={"aws_request_id": context.aws_request_id, "function_name": context.function_name}) raise4.Connect your agent with the server URL and a sign-in (Claude Code shown; Cursor, claude.ai and ChatGPT take the same URL).
terminalbashclaude mcp add --transport http runheed https://runheed.com/api/mcp
The npm and PyPI releases are not out yet, so these commands install the same package files straight from runheed.com. Nothing else changes when the registry versions ship.
What it catches
- Exceptions thrown in the handler, with the request id, function name and stack trace
- Errors you report yourself with captureException / capture_exception and any context you pass
- The same pattern works for API Gateway, SQS, EventBridge and scheduled invocations
What it does not do
- A timeout ("Task timed out") or running out of memory ends the invocation before your code can report it
- Reporting adds the time of one HTTPS request to a failed invocation (flush() in Node.js, the capture call itself in Python)
- Errors raised while the module loads, before the handler runs, need their own try/except around the import
Then ask your agent
> what broke in production since the last deploy? fix the top one and resolve it with the commit hash
Common AWS Lambda (Node.js and Python) errors
- TypeError: Cannot read properties of undefined (reading 'x')
- KeyError: 'email'
- [UnhandledPromiseRejection: This error originated either by throwing inside of an async...
- CredentialsProviderError: Could not load credentials from any providers
- botocore.exceptions.NoCredentialsError: Unable to locate credentials
- Error: Cannot find module 'x'
- ModuleNotFoundError: No module named 'x'
- TypeError: fetch failed