Async函数停止处理,并且无法仅在生产aws ec2集群上抛出exc



当我将以下代码部署到生产站点时,遇到了无法解释的错误。在当地,所有这些功能都经过了测试并正常工作。

我试着深入了解那些似乎失败的承诺,但它们并没有让任何例外。usersApiGateway.getNonce是一个get请求,当我在POSTMAN上发送get请求时,我验证了我得到了正确的返回值。

在我的AWS日志中,它基本上显示它执行到下面指定的点,然后停止。大约10分钟后,它停止了通过asyncTimeout调用进程的尝试,然后它被永久卡住了。如果能为我找到根本原因提供任何帮助,我们将不胜感激。

违规功能:

async createBuyOrder(tokenAddress, amountSell, amountBuy) {
amountSell = new BigNumber(amountSell);
amountBuy  = new BigNumber(amountBuy);
let nonce = '';
[amountBuy, amountSell, nonce] = await Promise.all([
web3Service.convertToWei(tokenAddress, amountBuy),
web3Service.convertToWei(ETHER_ADDRESS, amountSell),
usersApiGateway.getNonce(this.adminAccount)
]);
// FUNCTION FAILS TO RETURN ANYTHING AFTER THIS POINT
// Console.log for nonce, amount buy/sell/buy order below fail to show up
// that is what I mean by not working
const buyOrder = {
"addressBuy" : tokenAddress,
"amountBuy"  : amountBuy,
"addressSell": ETHER_ADDRESS,
"amountSell" : amountSell,
"nonce"      : nonce,
}
await this.createOrder(buyOrder);
}

这是从这个函数调用的:

async populateOrderBook(tokenAddress, numOrders = 1) {
for(let i = numOrders; i > 0; i--) {
for(let j = -1; j < numOrders - i; j++){
try {
await this.createBuyOrder(tokenAddress, BUYORDER_amountSell, BUYORDER_amountBuy);
await this.createSellOrder(tokenAddress, SELLORDER_amountBuy, SELLORDER_amountSell);
} catch(exc) {
console.log(exc)
}
}
}
}

在类的init()函数中定期调用

asyncTimeout(async () => {
try {
await Promise.all([
this.populateOrderBook(tokenAddress, 3)
]);
} catch (exc) {
console.error('Error while populating order book from Kyber');
console.error(exc);
}
}, 60000);

我已经测试了web3Service中似乎有问题的功能,它想挂起来,它在本地上似乎工作得很好

async convertToWei(tokenAddress, amount) {
const numberOfDecimals = await this.tokenDecimals(tokenAddress);
return new BigNumber(toBaseUnit(amount, numberOfDecimals));
}

事实证明,我与以太坊区块链的节点连接没有正常工作。我使用连接来确定convertToWei函数调用的小数位数,由于连接断开,它陷入了一个永远无法解决的循环中。

相关内容

  • 没有找到相关文章

最新更新