AWS callback warning
In my AWS logs for a S3 Bucket notification lambda that uses serverless-express, I get the following warning:
AWS Lambda plans to remove support for callback-based function handlers starting with Node.js 24. You will need to update this function to use an async handler to use Node.js 24 or later. For more information and to provide feedback on this change, see https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/issues/137. To disable this warning, set the AWS_LAMBDA_NODEJS_DISABLE_CALLBACK_WARNING environment variable.
This is how I'm creating the request handler:
export const handler = serverlessExpress({
app,
eventSourceRoutes: {
AWS_S3: "/s3",
},
});
Seems like serverless-express may need some internal update to be compatible with the new AWS updates?
Edit>> My version is 4.16.0
Safe to ignore that warning. SE supports callback for backwards compatibility
Thanks. Feel free to close if removing that backwards compatibility is not on the roadmap
@brettstack this is no longer true with Node.js 24, and even within the Node.js 22 runtime, if Managed Instances are being used it will throw:
ERROR: AWS Lambda does not support callback-based function handlers when using Node.js 22 with Managed Instances. To use Managed Instances, modify this function to use a supported handler signature. For more information see https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html.
They are checking for this via the Function.length parameter, so if backwards compatibility is desired the callback parameter shouldn't be called explicitly but checked either through ...args or arguments directly.