Skip to content

feat(wrappers): convert Lambda handler exports to async for nodejs20.x+ compatibility#216

Merged
czirker merged 1 commit intomasterfrom
feat/ES-2929-async-lambda-wrappers
Mar 11, 2026
Merged

feat(wrappers): convert Lambda handler exports to async for nodejs20.x+ compatibility#216
czirker merged 1 commit intomasterfrom
feat/ES-2929-async-lambda-wrappers

Conversation

@czirker
Copy link
Contributor

@czirker czirker commented Mar 11, 2026

Summary

  • Adds wrappers/wrapAsAsync.js — a shared utility that converts callback-style (event, context, callback) Lambda handlers into async handlers that return a Promise
  • Wraps all 4 Lambda wrapper exports (cron.js, fanout.js, resource.js, test.js) with wrapAsAsync() so they are compatible with newer Node.js Lambda runtimes (nodejs20.x, nodejs22.x) which no longer support the callback pattern
  • Zero changes to internal logic — the callback structure inside each wrapper is completely preserved; only the outermost return is wrapped

Jira

https://chb.atlassian.net/browse/ES-2929

Changes Made

File Change
wrappers/wrapAsAsync.js New — shared utility to convert callback handler → async handler
wrappers/cron.js Wrapped return with wrapAsAsync()
wrappers/fanout.js Wrapped return with wrapAsAsync()
wrappers/resource.js Wrapped return with wrapAsAsync()
wrappers/test.js Wrapped return with wrapAsAsync()

How It Works

// wrapAsAsync converts:
//   function(event, context, callback) { ... callback(null, result); }
// into:
//   async function(event, context) { return new Promise(...); }

Each wrapper factory now returns wrapAsAsync(function(event, context, callback) { ... }) instead of function(event, context, callback) { ... }. The internal callback-based flow is unchanged — wrapAsAsync creates the Promise at the boundary and connects it to the callback.

Testing

  • All 460 existing unit tests pass (JS + TS)
  • No internal logic changed — minimal regression risk
  • Backward compatible — existing consumers don't need code changes

Checklist

  • Code follows project style
  • Self-review completed
  • Tests pass (460/460)
  • Minimal, focused change

Made with Cursor


Note

Medium Risk
Changes the exported Lambda handler interface for cron, fanout, resource, and test wrappers from callback-style to Promise-returning async handlers, which can affect error/return propagation at the Lambda boundary. Internal wrapper logic is preserved, but any edge cases around double-callbacks or rejected Promises could surface at runtime.

Overview
Adds wrappers/wrapAsAsync.js, a small utility that adapts callback-style (event, context, callback) Lambda handlers into async handlers that return a Promise.

Updates the cron, fanout, resource, and test wrapper factories to return wrapAsAsync(...)-wrapped handlers so the exported entrypoints are compatible with Node.js 20+ Lambda runtimes while keeping existing callback-based internals unchanged.

Written by Cursor Bugbot for commit c9b4c5d. This will update automatically on new commits. Configure here.

…x+ compatibility

Newer AWS Lambda Node.js runtimes no longer support the callback-style
handler pattern. This wraps each handler export with wrapAsAsync() which
converts the callback-style function to an async function returning a
Promise, while preserving 100% of the internal callback logic unchanged.

Task: ES-2929
Made-with: Cursor
@czirker czirker merged commit f307326 into master Mar 11, 2026
5 checks passed
@czirker czirker deleted the feat/ES-2929-async-lambda-wrappers branch March 11, 2026 18:45
@ch-snyk-sa
Copy link

ch-snyk-sa commented Mar 11, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants