uni-app unicloud支付宝云请求网络超时 HttpClientRequestTimeoutError Request timeout for 10000 ms

uni-app unicloud支付宝云请求网络超时 HttpClientRequestTimeoutError Request timeout for 10000 ms

产品分类:

uniCloud/支付宝小程序云

App下载地址或H5网址:

小程序:我的物品录

示例代码:

// 获取库存充足商品
async getEnoughGoodsList({
  page = 1,
  pageSize = 20
}) {
  const dbObj = uniCloud.databaseForJQL({
    clientInfo: this.getClientInfo()
  });
  const uid = await checkLogin.call(this);
  if (typeof uid === 'object') {
    return uid;
  }

  try {
    const condition = {
      user_id: uid,
      $or: [{
          goods_threshold: null,
          goods_num: {
            $gt: 0
          }
        },
        {
          goods_threshold: '',
          goods_num: {
            $gt: 0
          }
        },
        {
          goods_num: null
        },
        {
          goods_num: ''
        },
        {
          $and: [{
              goods_threshold: {
                $exists: true,
                $ne: null,
                $ne: ''
              }
            },
            {
              goods_num: {
                $exists: true,
                $ne: null,
                $ne: ''
              }
            },
            {
              $expr: {
                $lt: ["$goods_threshold", "$goods_num"]
              }
            }
          ]
        }
      ]
    };
    const goodsInfo = await dbObj.collection('goods-info')
      .where(condition)
      .skip((page - 1) * pageSize)
      .limit(pageSize)
      .orderBy('last_modify_date', 'desc')
      .get();

    return {
      code: 0,
      msg: '获取成功',
      data: goodsInfo.data
    };
  } catch (error) {
    console.error('获取商品列表失败:', error);
    return {
      code: -2,
      msg: '获取商品列表失败',
      error: error.message
    };
  }
}

操作步骤:

  • 使用云对象

预期结果:

  • 能正常返回下一页的数据

实际结果:

  • 有时候第一页的数据无法返回,有时候第一页可以返回但是,下一页的数据无法返回

bug描述:

昨天好好的,今天出现超时问题,而且是多个用户出现这个问题,功能有时候可以,有时候就不可以,而且有时候uni-id-pages登录有超时 Error: HttpClientRequestTimeoutError: Request timeout for 10000 ms


更多关于uni-app unicloud支付宝云请求网络超时 HttpClientRequestTimeoutError Request timeout for 10000 ms的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

也许是数据库超时呢,你这没日志查不了的呀

更多关于uni-app unicloud支付宝云请求网络超时 HttpClientRequestTimeoutError Request timeout for 10000 ms的实战教程也可以访问 https://www.itying.com/category-93-b0.html


我也是HttpClientRequestTimeoutError: Request timeout for 10000 ms

这个错误是支付宝云函数请求超时导致的,主要可能有以下几个原因:

  1. 数据库查询条件较复杂,特别是使用了多个$or和$and嵌套,当数据量较大时可能导致查询超时。建议优化查询条件,减少复杂逻辑判断。

  2. 网络波动导致请求超时,可以尝试增加超时时间:

uniCloud.databaseForJQL({
  clientInfo: this.getClientInfo(),
  timeout: 20000 // 增加到20秒
});
回到顶部