Conversation
Added support for callback-style Lambda handlers in wrapAsAsync.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| // Support old runtimes that only accept callbacks and not async functions | ||
| if (callback != null){ | ||
| return handler(event, context, callback) | ||
| } |
There was a problem hiding this comment.
Async wrapper resolves prematurely on old runtimes
High Severity
When an old Lambda runtime provides a callback, the callback != null branch does return handler(event, context, callback). Since the wrapped handlers (in cron.js, fanout.js, resource.js, test.js) are callback-style and return undefined synchronously, and the wrapper is async, the implicit Promise immediately resolves with undefined. The Lambda runtime uses this resolved Promise as the response, completing the invocation before the handler's actual work finishes and the callback is called. This causes all wrapped handlers to return undefined on Node.js 18–22 runtimes.


Added support for callback-style Lambda handlers in wrapAsAsync.
Note
Low Risk
Low risk, small change isolated to
wrapAsAsyncto support legacy callback invocation. Main risk is subtle behavior differences if a runtime provides a callback while callers expect a Promise.Overview
Updates
wrapAsAsyncto accept an optionalcallbackargument and, when present, bypass Promise-wrapping and directly invoke the underlying handler with that callback.When no callback is provided, it keeps the existing behavior of converting callback-style handlers into a Promise-returning async handler.
Written by Cursor Bugbot for commit bcbce08. This will update automatically on new commits. Configure here.