From 8e2a4344bba215f6ad942f012a8827c455fb3664 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 12 Apr 2024 18:42:15 -0400 Subject: [PATCH] debugging missing order statuses --- order.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/order.js b/order.js index d40d6a8..6711ee9 100644 --- a/order.js +++ b/order.js @@ -13,17 +13,18 @@ export function sendVaultOrders( socket, chainId, vault ) { console.log('vault closed orders', closedIndexes) const statuses = {} const indexes = [...JSON.parse(openIndexes), ...JSON.parse(closedIndexes)] + const proms = [] if( openIndexes !== null ) { for (const orderIndex of indexes) { // there is a race condition here since we need multiple queries to get the complete order status, // so we check for nulls and exclude such an order, since it was deleted and no longer active. - const status = await orderStatus(chainId, vault, orderIndex) - if (status !== null) - statuses[orderIndex] = status + proms.push(orderStatus(chainId, vault, orderIndex).then((status)=>{ + if (status !== null) + statuses[orderIndex] = status + })) } } console.log('vault archived orders', recents) - const proms = [] for( let [orderIndex, status] of recents ) { if( !(orderIndex in statuses) ) { // only write the database version if there's no open order in the memcache @@ -47,7 +48,10 @@ export function unsubVaultOrders( socket, chainId, vault ) { export async function orderStatus( chainId, vault, orderIndex ) { const orderKey = `${vault}|${orderIndex}` let status = await orderStatuses.get(chainId, orderKey) - if( status !== null ) { + if( status === null ) { + console.warn(`Could not find order status for ${chainId}|${vault}|${orderIndex}`) + } + else { status = JSON.parse(status) await fillOrderStatus(chainId, orderKey, status) }