GramJs: Temporary workaround for logouts on launch, add WS logging (#1290)
This commit is contained in:
parent
4e4299bf39
commit
9794b62ec8
@ -79,12 +79,15 @@ export async function init(_onUpdate: OnApiUpdate, initialArgs: ApiInitialArgs)
|
|||||||
initialMethod: platform === 'iOS' || platform === 'Android' ? 'phoneNumber' : 'qrCode',
|
initialMethod: platform === 'iOS' || platform === 'Android' ? 'phoneNumber' : 'qrCode',
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
onUpdate({
|
// TODO Investigate which request causes this exception
|
||||||
'@type': 'updateConnectionState',
|
if (err.message !== 'Disconnect') {
|
||||||
connectionState: 'connectionStateBroken',
|
onUpdate({
|
||||||
});
|
'@type': 'updateConnectionState',
|
||||||
|
connectionState: 'connectionStateBroken',
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|||||||
@ -614,6 +614,7 @@ class TelegramClient {
|
|||||||
* @param request
|
* @param request
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async invoke(request) {
|
async invoke(request) {
|
||||||
if (request.classType !== 'request') {
|
if (request.classType !== 'request') {
|
||||||
throw new Error('You can only invoke MTProtoRequests');
|
throw new Error('You can only invoke MTProtoRequests');
|
||||||
|
|||||||
@ -56,6 +56,7 @@ export async function checkAuthorization(client: TelegramClient) {
|
|||||||
await client.invoke(new Api.updates.GetState());
|
await client.invoke(new Api.updates.GetState());
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (e.message === 'Disconnect') throw e;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,9 @@ class PromisedWebSockets {
|
|||||||
this.client.onerror = (error) => {
|
this.client.onerror = (error) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
};
|
};
|
||||||
this.client.onclose = () => {
|
this.client.onclose = (event) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(`Socket closed with code: ${event.code}`);
|
||||||
this.resolveRead(false);
|
this.resolveRead(false);
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user