简体   繁体   English

调试异步瀑布 AWS Lambda

[英]Debug async waterfall AWS Lambda

I am writing a lambda for converting images and I am using async.waterfall for it.我正在写一个 lambda 来转换图像,我正在使用 async.waterfall 。 I am having a hard time debugging the lambda, since it does not seem to start the second function transform.我很难调试 lambda,因为它似乎没有启动第二个 function 转换。 Can any body help me on debugging.任何机构都可以帮助我进行调试。 This is actually a pretty basic setup but I don't see why it does not go into the transform function nor throws any errors这实际上是一个非常基本的设置,但我不明白为什么它不会 go 转换为 function 也不会引发任何错误

    async.waterfall([
        function download(next) {
            
            s3.getObject({
                    Bucket: srcBucket,
                    Key: srcKey
                },
                next);
        },
        function transform(response, next) {
            console.log("transform", response);
            sharp(response.Body)
                .webp()
                .toBuffer(next);
        },
        function upload(data, info, next) {
            console.log("upload");
            s3.putObject({
                    Bucket: dstBucket,
                    Key: dstKey,
                    Body: data,
                },
                next);
        }
    ], function (err) {
        if (err) {
            console.error(
                'Unable to convert ' + srcBucket + '/' + srcKey +
                ' and upload to ' + dstBucket + '/' + dstKey +
                ' due to an error: ' + err
            );
        } else {
            console.log(
                'Successfully converted ' + srcBucket + '/' + srcKey +
                ' and uploaded to ' + dstBucket + '/' + dstKey
            );
        }
        callback(null, "message");
    });

If you are using AWS SAM, then you can start the lambda environment locally.如果您使用的是 AWS SAM,那么您可以在本地启动 lambda 环境。 Look at the possible options available here .查看此处可用的可能选项。 Invoking the code locally can help you debug the code.在本地调用代码可以帮助您调试代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM