add some logs to opengroup retry

pull/1677/head
Audric Ackermann 4 years ago
parent 9a9fb7271e
commit 94a0748d71
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -109,7 +109,7 @@ export async function removeSenderFromModerator(sender: string, convoId: string)
const pubKeyToRemove = PubKey.cast(sender);
const convo = ConversationController.getInstance().getOrThrow(convoId);
// FXIME audric removeModerator not working serverside
// FIXME audric removeModerator not working serverside
const roomInfo = convo.toOpenGroupV2();
const res = await ApiV2.removeModerator(pubKeyToRemove, roomInfo);
if (!res) {
@ -130,7 +130,6 @@ export async function addSenderAsModerator(sender: string, convoId: string) {
const pubKeyToRemove = PubKey.cast(sender);
const convo = ConversationController.getInstance().getOrThrow(convoId);
// FXIME audric addModerator not working serverside
const roomInfo = convo.toOpenGroupV2();
const res = await ApiV2.addModerator(pubKeyToRemove, roomInfo);
if (!res) {

@ -48,24 +48,24 @@ export async function getAuthToken({
await allowOnlyOneAtATime(`getAuthToken${serverUrl}:${roomId}`, async () => {
try {
window?.log?.info(
`Triggering getAuthToken with serverUrl:'${serverUrl}'; roomId:'${roomId}'`
`Triggering getAuthToken with serverUrl:'${serverUrl}'; roomId: '${roomId}'`
);
const token = await requestNewAuthToken({ serverUrl, roomId });
if (!token) {
window?.log?.warn('invalid new auth token', token);
return;
}
window?.log?.info(`Got AuthToken for serverUrl:'${serverUrl}'; roomId:'${roomId}'`);
window?.log?.info(`Got AuthToken for serverUrl:'${serverUrl}'; roomId: '${roomId}'`);
const claimedToken = await claimAuthToken(token, serverUrl, roomId);
if (!claimedToken) {
window?.log?.warn('Failed to claim token', claimedToken);
} else {
window?.log?.info(`Claimed AuthToken for serverUrl:'${serverUrl}'; roomId:'${roomId}'`);
window?.log?.info(`Claimed AuthToken for serverUrl:'${serverUrl}'; roomId: '${roomId}'`);
}
// still save it to the db. just to mark it as to be refreshed later
roomDetails.token = claimedToken || '';
await saveV2OpenGroupRoom(roomDetails);
window?.log?.info(`AuthToken saved to DB for serverUrl:'${serverUrl}'; roomId:'${roomId}'`);
window?.log?.info(`AuthToken saved to DB for serverUrl:'${serverUrl}'; roomId: '${roomId}'`);
} catch (e) {
window?.log?.error('Failed to getAuthToken', e);
throw e;

@ -338,12 +338,16 @@ export const getMemberCount = async (
};
const result = await exports.sendApiV2Request(request);
if (parseStatusCodeFromOnionRequest(result) !== 200) {
window?.log?.warn('getMemberCount failed invalid status code');
window?.log?.warn(
`getMemberCount failed invalid status code for serverUrl:'${roomInfos.serverUrl}' roomId:'${roomInfos.roomId}'`
);
return;
}
const count = parseMemberCount(result);
if (count === undefined) {
window?.log?.warn('getMemberCount failed invalid count');
window?.log?.warn(
`getMemberCount failed invalid count for serverUrl:'${roomInfos.serverUrl}' roomId:'${roomInfos.roomId}'`
);
return;
}

@ -203,7 +203,7 @@ const getCompactPollRequest = async (
roomRequestContent.from_message_server_id = lastMessageFetchedServerID;
} else {
window?.log?.info(
"We've been away for a long time... Only fetching last messages of room"
`We've been away for a long time... Only fetching last messages of room '${roomId}'`
);
}

@ -70,6 +70,7 @@ export class OpenGroupServerPoller {
constructor(roomInfos: Array<OpenGroupRequestCommonType>) {
autoBind(this);
if (!roomInfos?.length) {
throw new Error('Empty roomInfos list');
}
@ -80,9 +81,12 @@ export class OpenGroupServerPoller {
throw new Error('All rooms must be for the same serverUrl');
}
// first verify the rooms we got are all from on the same server
window?.log?.info(`Creating a new OpenGroupServerPoller for url ${firstUrl}`);
this.serverUrl = firstUrl;
roomInfos.forEach(r => {
window?.log?.info(
`Adding room on construct for url serverUrl: ${firstUrl}, roomId:'${r.roomId}' to poller:${this.serverUrl}`
);
this.roomIdsToPoll.add(r.roomId);
});
@ -114,6 +118,9 @@ export class OpenGroupServerPoller {
window?.log?.info('skipping addRoomToPoll of already polled room:', room);
return;
}
window?.log?.info(
`Adding room on addRoomToPoll for url serverUrl: ${this.serverUrl}, roomId:'${room.roomId}' to poller:${this.serverUrl}`
);
this.roomIdsToPoll.add(room.roomId);
// if we are not already polling right now, trigger a polling

@ -360,8 +360,12 @@ async function buildNewOnionPathsWorker() {
'LokiSnodeAPI::buildNewOnionPaths - Too few nodes to build an onion path! Refreshing pool and retrying'
);
await SnodePool.refreshRandomPool();
// FIXME this is a recursive call limited to only one call at a time. This cannot work
await buildNewOnionPathsOneAtATime();
// this is a recursive call limited to only one call at a time. we use the timeout
// here to make sure we retry this call if we cannot get enough otherNodes
setTimeout(async () => {
await buildNewOnionPathsOneAtATime();
}, 100);
return;
}

@ -14,6 +14,7 @@ import { PROTOCOLS } from '../constants';
import { toHex } from '../utils/String';
import pRetry from 'p-retry';
// FIXME audric we should soon be able to get rid of that
const FILESERVER_HOSTS = [
'file-dev.lokinet.org',
'file.lokinet.org',

Loading…
Cancel
Save