Reconnection bug

Hi,

I’am using Alpaca NodeJS library (“@alpacahq/alpaca-trade-api”: “^3.0.1”) and trying to get realtime market data using data_stream_v2.

It seems there is a bug on reconnect. Below is the source code of alpaca websocket.js.

onConnect(fn) {
    this.on(STATE.AUTHENTICATED, () => {
        if (this.session.isReconnected) {
            //if reconnected the user should subscribe to its symbols again
            this.subscribeAll();
        }
        else {
            fn();
        }
    });
}

It calls subscribeAll method and inside subscribeAll method checks for subscriptions.

subscribeAll() {
const { trades, quotes, bars, updatedBars, dailyBars, statuses, lulds } = this.session.subscriptions;
if (trades.length > 0 ||
quotes.length > 0 ||
bars.length > 0 ||
updatedBars.length > 0 ||
dailyBars.length > 0 ||
statuses.length > 0 ||
lulds.level > 0) {

Problem is all values (trades, quotes, bars, …) are undefined.

/Users/tansu/projects/howlet/howlet-api/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/stock_websocket_v2.js:70
if (trades.length > 0 ||
^
TypeError: Cannot read properties of undefined (reading ‘length’)
at AlpacaStocksClient.subscribeAll (/Users/tansu/projects/howlet/howlet-api/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/stock_websocket_v2.js:70:20)

Regards,

-tansu