Raygun Crash Reporting provider for AWS Lambda + Node.js, written in TypeScript.
Wraps AWS Lambda handlers to automatically capture uncaught errors and scope breadcrumbs per invocation.
Published on npm as @raygun.io/aws-lambda. Depends on the raygun Node.js client.
lib/— TypeScript source (single file:raygun.aws.ts). Compiled tobuild/viatsc.test/— JavaScript tests usingtap. Test utilities inutils.jsspin up a mock Express server to capture Raygun payloads.example/— Example AWS Lambda project demonstrating usage..github/workflows/— CI (Node 18/20/22 matrix: build, test, eslint, tseslint, prettier) and PR title linting (Conventional Commits).build/— Compiled output (gitignored). Entry point:build/raygun.aws.js+build/raygun.aws.d.ts.
npm ci # Install dependencies
npm run prepare # Compile TypeScript (tsc)
npm test # Run tests: tap --disable-coverage test/*_test.js
npm run eslint # Lint JS files (test/, example/)
npm run tseslint # Lint TS files (lib/)
npm run prettier # Format code- Language: TypeScript in
lib/, JavaScript intest/andexample/. - Module system: CommonJS (
module: "commonjs",target: "es5"). - Style: Double quotes, semicolons required, 2-space indentation, "one true brace style", arrow parens always. Enforced by ESLint + Prettier.
- Testing:
taptest framework. Tests require the TS source directly (require("../lib/raygun.aws")), not the compiled build. Each test creates an isolated mock server viamakeClientWithMockServer(). - PR titles: Must follow Conventional Commits (enforced by CI).
- The core export is
awsHandler(config, handler)which wraps an AWS Lambda handler (async or callback-style) to capture errors and scope breadcrumbs. - Callback-style handlers are converted to async via
createAsyncHandler. - Errors are sent to Raygun with the Lambda context as custom data and an
"AWS Handler"tag, then rethrown to AWS. - Breadcrumbs are scoped per invocation using
runWithBreadcrumbsAsyncfrom theraygunpackage.
This package is a lightweight wrapper around the raygun Node.js client (installed from npm as a runtime dependency).
Client(raygun): The main Raygun client class. Initialized externally and passed viaAwsHandlerConfig. Used forclient.send()andclient.addBreadcrumb().runWithBreadcrumbsAsync(raygun/build/raygun.breadcrumbs): Scopes breadcrumbs per Lambda invocation usingAsyncLocalStorage. Ensures breadcrumbs from concurrent invocations don't leak across requests.SendParameters(rayguntypes): The{ customData, tags }shape passed toclient.send().BreadcrumbMessage(rayguntypes): The shape passed toclient.addBreadcrumb()— includesmessage,level,category, andcustomData.
lib/raygun.ts— MainClientclass withsend(),addBreadcrumb(),init(),stop().lib/raygun.breadcrumbs.ts—addBreadcrumb(),getBreadcrumbs(),runWithBreadcrumbsAsync(),clear().lib/types.ts— All shared TypeScript types (Breadcrumb,SendParameters,CustomData, etc.).
- Do not add unnecessary dependencies; this is a lightweight wrapper around the
raygunclient. - The
raygunpackage is a runtime dependency;@types/aws-lambdaprovides Lambda type definitions. - Releases follow semver. See
RELEASING.mdfor the full release process. - CI runs on Node 18, 20, and 22. Ensure compatibility with all LTS versions.