From 28819c6290670abccf8769b1e2f40b3ce7e08a84 Mon Sep 17 00:00:00 2001 From: "Samuel EF. Tinnerholm" Date: Sun, 24 May 2026 20:24:44 +0300 Subject: [PATCH] fix: handle fire-and-forget async in chainlink feed Fixes #293 Fixes #300 --- core/src/feeds/chainlink/chainlink-feed.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/feeds/chainlink/chainlink-feed.ts b/core/src/feeds/chainlink/chainlink-feed.ts index 761a4eaa..7c41048f 100644 --- a/core/src/feeds/chainlink/chainlink-feed.ts +++ b/core/src/feeds/chainlink/chainlink-feed.ts @@ -2,6 +2,7 @@ import WebSocket from 'ws'; import axios, { AxiosInstance } from 'axios'; import { BaseDataFeed, DataFeedOptions } from '../base-feed'; import { Ticker, Tickers, OHLCV, OrderBook, Market, OracleRound, OracleParams, Dictionary } from '../types'; +import { logger } from '../../utils/logger'; import { ChainlinkFeedConfig, ChainlinkLatestPricesResponse, @@ -163,7 +164,9 @@ export class ChainlinkFeed extends BaseDataFeed { protected watchTickerImpl(symbol: string, callback: (ticker: Ticker) => void): () => void { const sub: Subscription = { symbol: symbol.toUpperCase(), callback }; this.subscriptions = [...this.subscriptions, sub]; - this.ensureConnected(); + this.ensureConnected().catch((err: unknown) => { + logger.error('[ChainlinkFeed] initial connect failed in watchTickerImpl:', err instanceof Error ? err.message : String(err)); + }); return () => { this.subscriptions = this.subscriptions.filter((s) => s !== sub); @@ -323,7 +326,11 @@ export class ChainlinkFeed extends BaseDataFeed { if (this.reconnectTimer) return; this.reconnectTimer = setTimeout(() => { this.reconnectTimer = null; - if (!this.isTerminated) this.connect(); + if (!this.isTerminated) { + this.connect().catch((err: unknown) => { + logger.error('[ChainlinkFeed] reconnect failed:', err instanceof Error ? err.message : String(err)); + }); + } }, this.reconnectIntervalMs); } }