AWS Lambda 未运行 for 循环

问题描述

我正在尝试在我的 AWS Lambda 中运行一个循环遍历数组的 for 循环。数组的长度为 11,但 for 循环在停止之前只运行了 3 次迭代(我在 try/catch 日志中找不到错误)。

代码是 Github 机器人的一部分,基本上将文件从存储库中的一个位置移动到另一个位置。

这段代码在 Heroku 上运行良好,但当我将它转移到 AWS lambda(使用无服务器框架)时它不起作用。

const workFlow = async (context) => {
  console.log("Getting files")
  let files = await context.octokit.repos.getContent({
    owner: context.payload.repository.owner.login,repo: context.payload.repository.name,path: ".bit/workflows"
  });

  console.log(files)
  console.log(files.data.length);
  for (i = 0; i < files.data.length; i++) {
    let body = await data.getFileContent(context,`.bit/workflows/${files.data[i].name}`)
    body = body[0].data.content

    try {
      console.log("Getting file " + i)
      console.log(files.data[i])
      await context.octokit.repos.createOrUpdateFileContents({
        owner: context.payload.repository.owner.login,path: `.github/workflows/${files.data[i].name}`,message: "Start workflows",content: body,committer: {
          name: `NAME`,email: "EMAIL",},author: {
          name: `NAME`,})
      console.log("Got workfow files");
    } catch (e) {
      console.log("Error in getting workflow files")
      console.log(e)
    }
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...