Skip to content

[FEEDBACK REQUEST] Should AWS Lambda deprecate callback-style function handlers for Node.js 24 and later? #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maxday opened this issue May 7, 2025 · 14 comments

Comments

@maxday
Copy link
Contributor

maxday commented May 7, 2025

👍 👎 The AWS Lambda Runtimes team would love your thoughts! Please upvote/downvote to indicate if you support this change.

Currently, AWS Lambda supports both callback-style and async/await function handler signatures. Considering Node.js has fully embraced async/await, we are considering removing support for callback style function handlers starting with our Node.js 24 release later this year. With this change, customers currently using the callback signature will need to update their code to use the async/await signature when migrating their functions to Node.js 24 or later runtimes.

This proposal applies to Node.js 24 and later runtimes only. We will continue to support both callback and async/await function handler signatures in our existing Node.js 18, Node.js 20, and Node.js 22 runtimes.

Current callback-style: (to be removed)

exports.handler = (event, context, callback) => {
  // ... handler logic
  callback(null, { statusCode: 200, body: 'Success!' });
};

Async/await style: (to be kept as-is)

export const handler = async (event, context) => {
  // ... handler logic
  return { statusCode: 200, body: 'Success!' };
};

Should we make this change? Please vote!
👍 : Yes, in favor of deprecating the callback handler signature.
👎 : No, keep the callback handler signature.

Please also share any feedback in the comments.

@astuyve
Copy link

astuyve commented May 7, 2025

Definitely deprecate it.

People either use it accidentally (due to old examples or documentation), or think that setting callbackWaitsForEmptyEventLoop to false is a way to perform compute after the handler exits (not realizing that those promises are only driven during subsequent invocations and can fail silently or dropped entirely on shutdown/timeout/suppressed init).

@arnabrahman
Copy link

Yes, sir

@dvddpl
Copy link

dvddpl commented May 7, 2025

absolutely deprecate it please!

@willfarrell
Copy link

willfarrell commented May 7, 2025

I've add this to the Middy roadmap to revisit for future major releases. We dropped support for callbacks many yers ago, but still have references within the code.

@TrickSumo
Copy link

Yes

@dreamorosi
Copy link

dreamorosi commented May 8, 2025

I literally never use it and I agree with the general sentiment of deprecating it, but the proposal is missing some info on what are the benefits of doing this. Will it help customers in any way, or will it bring performance improvements, or?

I imagine that having this info would help others who still use it better evaluate the tradeoffs.

@dignat
Copy link

dignat commented May 8, 2025

Yes deprecated please

👍

@uafaruqi
Copy link

uafaruqi commented May 8, 2025

+1

I literally never use it and I agree with the general sentiment of deprecating it, but the proposal is missing some info on what are the benefits of doing this. Will it help customers in any way, or will it bring performance improvements, or?

I imagine that having this info would help others who still use it better evaluate the tradeoffs.

@aripalo
Copy link

aripalo commented May 9, 2025

Yes please, deprecate the callback pattern.

Although not a major issue, but currently having that callback pattern as an option can sometimes lead to people (i.e. developers new to Lambda) to use it "accidentally" (meaning without understanding there are better patterns. So deprecating that callback pattern would mean one thing less to teach / advocate (against) about.

@maxday
Copy link
Contributor Author

maxday commented May 9, 2025

Firstly, thank you so much for your feedback!

Here are a few more details on why we're thinking about deprecating the callback handler:

  1. Modernization. async/await has been introduced in ES2017 and Node.js has fully embraced it. If you're using a third-party package which uses async functions, you'll need to wrap it around promises and this adds complexity.

  2. Simplicity. As mentioned by @astuyve and @aripalo, having multiple ways of defining a handler leads to confusion. You can achieve the same behavior using one or the other, so keeping both of them might be confusing.

@lmammino
Copy link

lmammino commented May 9, 2025

I agree with the idea of deprecating the callback pattern.

One thing to consider is that communication might be more challenging than usual in this case. How can we ensure that all AWS examples, documentation, and repositories are properly updated to reflect this change?

It’s probably a good idea to issue warnings well in advance, just in case anyone is still relying on this feature. A more cautious approach could be to introduce a deprecation warning in the logs whenever the callback is used, starting with the Node.js 24 runtime. It would be even better if this could also be applied to previously supported runtimes. The feature could then be fully removed in the next major runtime release, such as Node.js 26.

@leleofg
Copy link

leleofg commented May 9, 2025

yessss

@Rexben001
Copy link

I agree! The async/await pattern has been the standard in modern JavaScript for years and is more intuitive and less error-prone than callback-based code.

@caiorhian
Copy link

I agree, should be deprecated!

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

No branches or pull requests