fix(receivers): make AwsLambdaReceiver.toHandler() promise-based (Node.js 24+)#2970
fix(receivers): make AwsLambdaReceiver.toHandler() promise-based (Node.js 24+)#2970tsushanth wants to merge 1 commit into
Conversation
…e.js 24+) Closes slackapi#2761. `AwsLambdaReceiver.toHandler()` returned a 3-arg function `(event, context, callback) => Promise<AwsResponse>`. AWS Lambda's Node.js 24+ runtime checks the handler's `.length` up front and rejects 3-arg handlers with `Runtime.CallbackHandlerDeprecated` before invoking it — every Bolt app deployed on the Node 24 runtime crashed at startup. The callback parameter was never actually invoked anywhere in the receiver (the handler always returned a `Promise<AwsResponse>` directly), so drop it from both the `AwsHandler` type and the implementation. The existing `AwsCallback` export is preserved for source compatibility and annotated `@deprecated` so consumers see the migration path on hover. Existing tests are updated to call the handler with two arguments; a regression test pins `handler.length === 2` so a future refactor that re-adds a trailing parameter doesn't silently break Node 24 again. All 488 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
Thanks for the contribution! Before we can merge this, we need @tsushanth to sign the Salesforce Inc. Contributor License Agreement. |
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: request context can be anything | ||
| export type AwsHandler = (event: AwsEvent, context: any, callback: AwsCallback) => Promise<AwsResponse>; | ||
| export type AwsHandler = (event: AwsEvent, context: any) => Promise<AwsResponse>; |
There was a problem hiding this comment.
praise: Good call dropping the callback from the exported type rather than just the implementation.
| signingSecret: 'my-secret', | ||
| logger: noopLogger, | ||
| }); | ||
| const handler = awsReceiver.toHandler(); |
There was a problem hiding this comment.
praise: Thanks for assert.equal(handler.length, 2) to pin the handler, since that is the exact value Lambda runtime reads.
Closes #2761.
Summary
AwsLambdaReceiver.toHandler()returns a 3-arg function(event, context, callback) => Promise<AwsResponse>. AWS Lambda's Node.js 24+ runtime inspects the handler's.lengthat registration and rejects 3-arg handlers withRuntime.CallbackHandlerDeprecatedbefore they're ever invoked, so every Bolt app deployed on the Node 24 runtime crashes at startup.The callback parameter was never actually invoked anywhere in the receiver — the handler always returned
Promise<AwsResponse>directly — so drop it from both theAwsHandlertype and the implementation.The existing
AwsCallbackexport is preserved for source compatibility and annotated@deprecatedso consumers see the migration path on hover.Tests
AwsLambdaReceiver.spec.tsupdated fromhandler(event, {}, (_e, _r) => {})tohandler(event, {}).handler.length === 2so a future refactor that re-adds a trailing parameter doesn't silently break Node 24 again.All 488 unit tests pass.