@adaptic/utils 0.0.969 → 0.0.971

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2921,10 +2921,25 @@ class AlpacaMarketDataAPI extends require$$0$1.EventEmitter {
2921
2921
  });
2922
2922
  }
2923
2923
  }
2924
+ else if (ws && ws.readyState === WebSocket.CONNECTING) {
2925
+ // WebSocket is still establishing. Subscriptions are already persisted
2926
+ // in `subscriptions` and will be dispatched automatically by the
2927
+ // auth-success handler once the stream authenticates. This is the
2928
+ // expected transient state during startup / reconnect — not a failure.
2929
+ const queuedTotal = (subscriptions.trades?.length || 0) +
2930
+ (subscriptions.quotes?.length || 0) +
2931
+ (subscriptions.bars?.length || 0);
2932
+ log$l(`${streamType} subscription queued (${queuedTotal} channel entries); will dispatch after WebSocket authenticates`, { type: "debug" });
2933
+ }
2924
2934
  else {
2925
- log$l(`Cannot send ${streamType} subscription: WebSocket not ready`, {
2926
- type: "warn",
2927
- });
2935
+ const stateLabel = ws === null
2936
+ ? "null"
2937
+ : ws.readyState === WebSocket.CLOSING
2938
+ ? "CLOSING"
2939
+ : ws.readyState === WebSocket.CLOSED
2940
+ ? "CLOSED"
2941
+ : `unknown(${ws.readyState})`;
2942
+ log$l(`Cannot send ${streamType} subscription: WebSocket in ${stateLabel} state`, { type: "warn" });
2928
2943
  }
2929
2944
  }
2930
2945
  connectStockStream() {