Skip to content

Commit

Permalink
Fixed await and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukaihan committed Feb 27, 2024
1 parent 2ead68c commit adb8310
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/experiment-core/src/api/stream-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '../transport/stream';

const DEFAULT_INITIAL_CONN_TIMEOUT = 1000; // Initial connection timeout.
const MAX_CONN_MS_MIN = 12 * 60 * 1000; // Max connection timeout and wants to automatically disconnect and reconnects.
const MAX_CONN_MS_MAX = 18 * 60 * 1000; // Min timeout as above.
const MAX_CONN_MS_MIN = 12 * 60 * 1000; // Min of max connection timeout and wants to automatically disconnect and reconnects.
const MAX_CONN_MS_MAX = 18 * 60 * 1000; // Max of the above timeout.
const KEEP_ALIVE_INTERVAL = (15 + 2) * 1000; // 15 seconds plus 2 seconds grace period. // 0 or neg value disables keep alive.
const KEEP_ALIVE_DATA = ' ';

Expand Down Expand Up @@ -108,7 +108,7 @@ export class SdkStreamApi implements StreamApi {
this.reconnectionTimeout = setTimeout(async () => {
if (es.readyState == this.eventSourceClass.OPEN) {
// The es is being checked, not this.eventSource. So it won't affect new connections.
await this.close();
this.close();
this.connect();
}
}, randomReconnectionTimeout);
Expand Down Expand Up @@ -151,7 +151,7 @@ export class SdkStreamApi implements StreamApi {
}

private async error(err: StreamErrorEvent) {
await this.close();
this.close();
if (this.onError) {
try {
this.onError(err);
Expand Down
1 change: 1 addition & 0 deletions packages/experiment-core/src/transport/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface StreamEventSource {
onopen: (evt: StreamOpenEvent) => any;
onmessage: (evt: StreamMessageEvent) => any;
onerror: (evt: StreamErrorEvent) => any;
// The following are in specs but not currently used. Uncomment as we start to use them.
// addEventListener(type: string, listener: (evt: StreamEvent) => void): void;
// dispatchEvent(evt: Event): boolean;
// removeEventListener(type: string, listener: (evt: StreamEvent) => void): void;
Expand Down

0 comments on commit adb8310

Please sign in to comment.