@adaptic/utils 0.0.968 → 0.0.970

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.mjs CHANGED
@@ -2919,10 +2919,25 @@ class AlpacaMarketDataAPI extends EventEmitter {
2919
2919
  });
2920
2920
  }
2921
2921
  }
2922
+ else if (ws && ws.readyState === WebSocket.CONNECTING) {
2923
+ // WebSocket is still establishing. Subscriptions are already persisted
2924
+ // in `subscriptions` and will be dispatched automatically by the
2925
+ // auth-success handler once the stream authenticates. This is the
2926
+ // expected transient state during startup / reconnect — not a failure.
2927
+ const queuedTotal = (subscriptions.trades?.length || 0) +
2928
+ (subscriptions.quotes?.length || 0) +
2929
+ (subscriptions.bars?.length || 0);
2930
+ log$l(`${streamType} subscription queued (${queuedTotal} channel entries); will dispatch after WebSocket authenticates`, { type: "debug" });
2931
+ }
2922
2932
  else {
2923
- log$l(`Cannot send ${streamType} subscription: WebSocket not ready`, {
2924
- type: "warn",
2925
- });
2933
+ const stateLabel = ws === null
2934
+ ? "null"
2935
+ : ws.readyState === WebSocket.CLOSING
2936
+ ? "CLOSING"
2937
+ : ws.readyState === WebSocket.CLOSED
2938
+ ? "CLOSED"
2939
+ : `unknown(${ws.readyState})`;
2940
+ log$l(`Cannot send ${streamType} subscription: WebSocket in ${stateLabel} state`, { type: "warn" });
2926
2941
  }
2927
2942
  }
2928
2943
  connectStockStream() {