- I created an API Gateway + lambda for
signUpwithamazon-cognito-identity-js. - Then I implemented a Cognito trigger function for preSignUp with Typescript
I use Serverless framework to pack and deploy. The runtime is Node 12
+++++++
const wrapperHandler: Handler<CognitoUserPoolEvent> = async (
event,
context,
callback
) => {
let error = null;
try {
await myAsyncFunc();
} catch (e) {
error = e;
}
callback(error, event);
};
Everything works fine, it can return the error to the actual endpoint lambda which will then be returned, if no error, the logic will be executed.
However, this warning is pretty annoying.
The code is for preSignUp in CloudWatch
WARNING: Callback/response already delivered. Did your function invoke the callback and also return a promise? For more details, see: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
In the code, I didn't return anything before calling the callback, why would this happen? and how to solve it.