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. 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.

    terminalbash
    npm 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 ./package
  2. 2.Node.js: initialize outside the handler (once per cold start), then report, flush and rethrow.

    index.mjsjavascript
    import 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. 3.Python: the SDK sends the event before capture_exception returns, so there is nothing to flush. Report and re-raise.

    lambda_function.pypython
    import 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})
            raise
  4. 4.Connect your agent with the server URL and a sign-in (Claude Code shown; Cursor, claude.ai and ChatGPT take the same URL).

    terminalbash
    claude 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

Plans from $29/moOther agents and editorsCancel any time from the billing portal