Skip to content

handler() from hono/lambda-edge triggers Runtime.CallbackHandlerDeprecated on NODEJS_24_X #4772

@rcolwell-cb

Description

@rcolwell-cb

What version of Hono are you using?

4.12.2

What runtime/platform is your app running on? (with version if possible)

AWS/CloudFront Lambda@edge Node 24

What steps can reproduce the bug?

The handle() function exported from hono/lambda-edge returns an async function with three parameters:
// node_modules/hono/dist/adapter/lambda-edge/handler.js var handle = (app) => { return async (event, context, callback) => { // ... } }

Because the returned function has .length === 3, the AWS Lambda runtime identifies it as a callback-style handler. Starting with NODEJS_24_X, AWS Lambda has deprecated callback-based handlers, producing:

This happens even though the function is async and returns a Promise — the runtime uses handler.length (i.e., the number of formal parameters) to determine the handler type, not whether it's actually async.

Reproduction:

Create a Lambda@Edge function using hono/lambda-edge
Deploy with runtime: lambda.Runtime.NODEJS_24_X
Invoke the function — it fails with Runtime.CallbackHandlerDeprecated

What is the expected behavior?

(more claude opus output...)

The handler returned by handle(app) should work on all supported Node.js Lambda runtimes (NODEJS_18_X through NODEJS_24_X) without requiring a wrapper. Since callback is already optional and the function is already async, the returned function should have .length <= 2 so the Lambda runtime correctly identifies it as an async handler. On older runtimes that still support callbacks, the behavior would be unchanged — callback can still be passed positionally and used via c.env.callback() — but it should not be a formal parameter that inflates Function.length.

What do you see instead?

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions