From bcbce08bf09cf63e4c94d62e27627a4f8fef904d Mon Sep 17 00:00:00 2001 From: czirker <45575356+czirker@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:50:38 -0600 Subject: [PATCH] Enhance wrapAsAsync to support callbacks Added support for callback-style Lambda handlers in wrapAsAsync. --- wrappers/wrapAsAsync.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wrappers/wrapAsAsync.js b/wrappers/wrapAsAsync.js index 1af80a8..82c775b 100644 --- a/wrappers/wrapAsAsync.js +++ b/wrappers/wrapAsAsync.js @@ -9,9 +9,13 @@ * @returns {function(event, context): Promise} An async Lambda handler */ module.exports = function wrapAsAsync(handler) { - return async function(event, context) { + return async function(event, context, callback) { + // Support old runtimes that only accept callbacks and not async functions + if (callback != null){ + return handler(event, context, callback) + } return new Promise((resolve, reject) => { - handler(event, context, function(err, result) { + return handler(event, context, function(err, result) { if (err) reject(err); else resolve(result); });