Skip to content

Commit

Permalink
fix: added missing logs for wsconnection (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Jan 25, 2022
1 parent d0c0e5d commit 94bd909
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ export class StableWSConnection<
this.requestID = randomId();
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
try {
this._log(`_connect() - waiting for token`);
await this.client.tokenManager.tokenReady();
this._setupConnectionPromise();
const wsURL = this._buildUrl();
this._log(`_connect() - Connecting to ${wsURL}`, { wsURL, requestID: this.requestID });
this.ws = new WebSocket(wsURL);
this.ws.onopen = this.onopen.bind(this, this.wsID);
this.ws.onclose = this.onclose.bind(this, this.wsID);
Expand Down Expand Up @@ -412,6 +414,7 @@ export class StableWSConnection<
onmessage = (wsID: number, event: WebSocket.MessageEvent) => {
if (this.wsID !== wsID) return;

this._log('onmessage() - onmessage callback', { event, wsID });
const data = typeof event.data === 'string' ? JSON.parse(event.data) : null;

// we wait till the first message before we consider the connection open..
Expand All @@ -430,7 +433,6 @@ export class StableWSConnection<

// trigger the event..
this.lastEvent = new Date();
this._log('onmessage() - onmessage callback', { event, wsID });

if (data && data.type === 'health.check') {
this.scheduleNextPing();
Expand Down

0 comments on commit 94bd909

Please sign in to comment.