From b1c6cc4f31fe392c690499e599ba6405464d7bbe Mon Sep 17 00:00:00 2001 From: "Samuel EF. Tinnerholm" Date: Sun, 24 May 2026 20:24:40 +0300 Subject: [PATCH] fix: handle fire-and-forget async in binance feed Fixes #280 Fixes #288 --- core/src/feeds/binance/binance-feed.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/feeds/binance/binance-feed.ts b/core/src/feeds/binance/binance-feed.ts index 5385f138..9606472d 100644 --- a/core/src/feeds/binance/binance-feed.ts +++ b/core/src/feeds/binance/binance-feed.ts @@ -1,4 +1,5 @@ import WebSocket from 'ws'; +import { logger } from '../../utils/logger'; import { BaseDataFeed, DataFeedOptions } from '../base-feed'; import { Ticker, Tickers, OHLCV, OrderBook, Market, Dictionary } from '../types'; import { BinanceFeedConfig, BinanceRelayMessage, BinanceRelayTradeEvent, BINANCE_RELAY_DEFAULTS } from './types'; @@ -122,7 +123,11 @@ export class BinanceFeed extends BaseDataFeed { protected watchTickerImpl(symbol: string, callback: (ticker: Ticker) => void): () => void { const sub: Subscription = { symbol, callback }; this.subscriptions = [...this.subscriptions, sub]; - this.ensureConnected(); + this.ensureConnected().catch((err: unknown) => { + logger.error('[BinanceFeed] initial connect failed in watchTickerImpl', { + error: err instanceof Error ? err.message : String(err), + }); + }); return () => { this.subscriptions = this.subscriptions.filter((s) => s !== sub); @@ -221,7 +226,11 @@ export class BinanceFeed extends BaseDataFeed { this.reconnectTimer = setTimeout(() => { this.reconnectTimer = null; if (!this.isTerminated) { - this.connect(); + this.connect().catch((err: unknown) => { + logger.error('[BinanceFeed] reconnect failed', { + error: err instanceof Error ? err.message : String(err), + }); + }); } }, this.reconnectIntervalMs); }