From cb8e3a1e12246d029fbc165caa5580c676328d33 Mon Sep 17 00:00:00 2001 From: Christopher-Li Date: Tue, 31 Oct 2023 13:10:37 -0400 Subject: [PATCH] [IND-458]: In case of errors in comlink log request (#722) --- .../comlink/src/controllers/api/v4/addresses-controller.ts | 2 ++ .../src/controllers/api/v4/asset-positions-controller.ts | 1 + .../comlink/src/controllers/api/v4/candles-controller.ts | 1 + .../comlink/src/controllers/api/v4/compliance-controller.ts | 1 + .../comlink/src/controllers/api/v4/fills-controller.ts | 1 + .../comlink/src/controllers/api/v4/height-controller.ts | 3 ++- .../src/controllers/api/v4/historical-funding-controller.ts | 1 + .../src/controllers/api/v4/historical-pnl-controller.ts | 1 + .../comlink/src/controllers/api/v4/orderbook-controller.ts | 1 + .../comlink/src/controllers/api/v4/orders-controller.ts | 2 ++ .../src/controllers/api/v4/perpetual-markets-controller.ts | 1 + .../src/controllers/api/v4/perpetual-positions-controller.ts | 1 + .../comlink/src/controllers/api/v4/sparklines-controller.ts | 1 + .../comlink/src/controllers/api/v4/trades-controller.ts | 1 + .../comlink/src/controllers/api/v4/transfers-controller.ts | 1 + indexer/services/comlink/src/lib/helpers.ts | 5 +++++ 16 files changed, 23 insertions(+), 1 deletion(-) diff --git a/indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts b/indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts index 8d0081e491..dad65ae2f7 100644 --- a/indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts @@ -269,6 +269,7 @@ router.get( 'AddressesController GET /:address', 'Addresses error', error, + req, res, ); } @@ -308,6 +309,7 @@ router.get( 'AddressesController GET /:address/subaccountNumber/:subaccountNumber', 'Addresses subaccount error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/asset-positions-controller.ts b/indexer/services/comlink/src/controllers/api/v4/asset-positions-controller.ts index 2ac642756f..63aa7dccc1 100644 --- a/indexer/services/comlink/src/controllers/api/v4/asset-positions-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/asset-positions-controller.ts @@ -174,6 +174,7 @@ router.get( 'AssetPositionsController GET /', 'Asset positions error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/candles-controller.ts b/indexer/services/comlink/src/controllers/api/v4/candles-controller.ts index b25571d64a..28a6ddfc85 100644 --- a/indexer/services/comlink/src/controllers/api/v4/candles-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/candles-controller.ts @@ -101,6 +101,7 @@ router.get( 'CandlesController GET /perpetualMarkets/:ticker', 'Candles error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/compliance-controller.ts b/indexer/services/comlink/src/controllers/api/v4/compliance-controller.ts index 501a2535dd..40aa9bc4c6 100644 --- a/indexer/services/comlink/src/controllers/api/v4/compliance-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/compliance-controller.ts @@ -144,6 +144,7 @@ router.get( 'ComplianceController GET /', 'Compliance error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/fills-controller.ts b/indexer/services/comlink/src/controllers/api/v4/fills-controller.ts index fa4ac8cacd..0a241c8e78 100644 --- a/indexer/services/comlink/src/controllers/api/v4/fills-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/fills-controller.ts @@ -161,6 +161,7 @@ router.get( 'FillsController GET /', 'Fills error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/height-controller.ts b/indexer/services/comlink/src/controllers/api/v4/height-controller.ts index 018fd8fa6c..b6d6a0dbdd 100644 --- a/indexer/services/comlink/src/controllers/api/v4/height-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/height-controller.ts @@ -37,7 +37,7 @@ router.get( rejectRestrictedCountries, rateLimiterMiddleware(getReqRateLimiter), ExportResponseCodeStats({ controllerName }), - async (_req: express.Request, res: express.Response) => { + async (req: express.Request, res: express.Response) => { const start: number = Date.now(); try { const controller: HeightController = new HeightController(); @@ -49,6 +49,7 @@ router.get( 'HeightController GET /', 'Height error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/historical-funding-controller.ts b/indexer/services/comlink/src/controllers/api/v4/historical-funding-controller.ts index ea64e0e2e0..a256521d40 100644 --- a/indexer/services/comlink/src/controllers/api/v4/historical-funding-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/historical-funding-controller.ts @@ -116,6 +116,7 @@ router.get( 'HistoricalFundingController GET /', 'HistoricalFunding error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/historical-pnl-controller.ts b/indexer/services/comlink/src/controllers/api/v4/historical-pnl-controller.ts index 687b3da264..e2045389e1 100644 --- a/indexer/services/comlink/src/controllers/api/v4/historical-pnl-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/historical-pnl-controller.ts @@ -128,6 +128,7 @@ router.get( 'HistoricalPnlController GET /', 'Historical Pnl error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/orderbook-controller.ts b/indexer/services/comlink/src/controllers/api/v4/orderbook-controller.ts index d80822e1b5..7c80ce35f4 100644 --- a/indexer/services/comlink/src/controllers/api/v4/orderbook-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/orderbook-controller.ts @@ -79,6 +79,7 @@ router.get( 'OrderbooksController GET /perpetualMarket/:ticker', 'Orderbooks error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts b/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts index 4c65a72971..19466174cb 100644 --- a/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/orders-controller.ts @@ -262,6 +262,7 @@ router.get( 'OrdersController GET /', 'Orders error', error, + req, res, ); } finally { @@ -300,6 +301,7 @@ router.get( 'OrdersController GET /:orderId', 'Orders error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/perpetual-markets-controller.ts b/indexer/services/comlink/src/controllers/api/v4/perpetual-markets-controller.ts index 6c1dda4ff1..0962f98b1f 100644 --- a/indexer/services/comlink/src/controllers/api/v4/perpetual-markets-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/perpetual-markets-controller.ts @@ -142,6 +142,7 @@ router.get( 'PerpetualMarketController GET /', 'PerpetualMarket error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/perpetual-positions-controller.ts b/indexer/services/comlink/src/controllers/api/v4/perpetual-positions-controller.ts index 3815be5a4e..eadba62063 100644 --- a/indexer/services/comlink/src/controllers/api/v4/perpetual-positions-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/perpetual-positions-controller.ts @@ -198,6 +198,7 @@ router.get( 'PerpetualPositionsController GET /', 'Perpetual positions error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/sparklines-controller.ts b/indexer/services/comlink/src/controllers/api/v4/sparklines-controller.ts index 8c82eb8642..a426c88eb4 100644 --- a/indexer/services/comlink/src/controllers/api/v4/sparklines-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/sparklines-controller.ts @@ -90,6 +90,7 @@ router.get( 'SparklinesController GET /', 'Sparklines error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/trades-controller.ts b/indexer/services/comlink/src/controllers/api/v4/trades-controller.ts index 87d7a6a428..a84cf515b1 100644 --- a/indexer/services/comlink/src/controllers/api/v4/trades-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/trades-controller.ts @@ -116,6 +116,7 @@ router.get( 'TradesController GET /perpetualMarket/:ticker', 'Trades error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/controllers/api/v4/transfers-controller.ts b/indexer/services/comlink/src/controllers/api/v4/transfers-controller.ts index c854f9c244..860d9019e8 100644 --- a/indexer/services/comlink/src/controllers/api/v4/transfers-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/transfers-controller.ts @@ -163,6 +163,7 @@ router.get( 'TransfersController GET /', 'Transfers error', error, + req, res, ); } finally { diff --git a/indexer/services/comlink/src/lib/helpers.ts b/indexer/services/comlink/src/lib/helpers.ts index 97927455dd..e9feb31700 100644 --- a/indexer/services/comlink/src/lib/helpers.ts +++ b/indexer/services/comlink/src/lib/helpers.ts @@ -48,6 +48,7 @@ export function handleControllerError( at: string, message: string, error: Error, + req: express.Request, res: express.Response, ): express.Response { if (error instanceof NotFoundError) { @@ -57,6 +58,7 @@ export function handleControllerError( at, message, error, + req, res, ); } @@ -65,6 +67,7 @@ function handleInternalServerError( at: string, message: string, error: Error, + req: express.Request, res: express.Response, ): express.Response { if (config.isDevelopment()) { @@ -76,6 +79,8 @@ function handleInternalServerError( at, message, error, + params: JSON.stringify(req.params), + query: JSON.stringify(req.query), }); return createInternalServerErrorResponse(res); }