Skip to content

Commit

Permalink
fix(client): Wait for server acknowledgement indefinitely
Browse files Browse the repository at this point in the history
Closes: enisdenjo#98
  • Loading branch information
enisdenjo committed Jan 19, 2021
1 parent b106dbe commit a4bd602
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ export function createClient(options: ClientOptions): Client {
let cancelled = false;
cancellerRef.current = () => (cancelled = true);

const tooLong = setTimeout(() => {
socket.close(3408, 'Waited 5 seconds but socket connect never settled');
}, 5 * 1000);

/**
* `onerror` handler is unnecessary because even if an error occurs, the `onclose` handler will be called
*
Expand All @@ -375,7 +371,6 @@ export function createClient(options: ClientOptions): Client {

socket.onclose = (event) => {
socket.onclose = null;
clearTimeout(tooLong);
state = { ...state, acknowledged: false, socket: null };
emitter.emit('closed', event);
return reject(event);
Expand All @@ -394,7 +389,6 @@ export function createClient(options: ClientOptions): Client {
throw new Error(`First message cannot be of type ${message.type}`);
}

clearTimeout(tooLong);
state = {
...state,
acknowledged: true,
Expand Down

0 comments on commit a4bd602

Please sign in to comment.