fix: add logs during polling

pull/3065/head
Audric Ackermann 2 months ago
parent cfcbc013e5
commit ae96936a1a

@ -1,4 +1,4 @@
import { omit } from 'lodash';
import { isArray, omit } from 'lodash';
import { Snode } from '../../../data/data';
import { updateIsOnline } from '../../../state/ducks/onion';
import { doSnodeBatchRequest } from './batchRequest';
@ -7,6 +7,7 @@ import { SnodeNamespace, SnodeNamespaces } from './namespaces';
import { TTL_DEFAULT } from '../../constants';
import { UserUtils } from '../../utils';
import { sleepFor } from '../../utils/Promise';
import {
RetrieveLegacyClosedGroupSubRequestType,
RetrieveSubRequestType,
@ -123,14 +124,12 @@ async function retrieveNextMessages(
);
// let exceptions bubble up
// no retry for this one as this a call we do every few seconds while polling for messages
const results = await doSnodeBatchRequest(
retrieveRequestsParams,
targetNode,
4000,
associatedWith
);
if (!results || !results.length) {
const timeOutMs = 4 * 1000;
const results = await Promise.race([
async () => doSnodeBatchRequest(retrieveRequestsParams, targetNode, timeOutMs, associatedWith),
async () => sleepFor(timeOutMs), // just to make sure that we don't hang for more than 4s
]);
if (!results || !isArray(results) || !results.length) {
window?.log?.warn(
`_retrieveNextMessages - sessionRpc could not talk to ${targetNode.ip}:${targetNode.port}`
);

@ -228,12 +228,21 @@ export class SwarmPolling {
let resultsFromAllNamespaces: RetrieveMessagesResultsBatched | null;
try {
// Note: always print something so we know if the polling is hanging
window.log.info(
`about to pollNodeForKey of ${ed25519Str(pubkey.key)} from snode: ${ed25519Str(toPollFrom.pubkey_ed25519)} namespaces: ${namespaces} `
);
resultsFromAllNamespaces = await this.pollNodeForKey(
toPollFrom,
pubkey,
namespaces,
!isGroup
);
// Note: always print something so we know if the polling is hanging
window.log.info(
`pollNodeForKey of ${ed25519Str(pubkey.key)} from snode: ${ed25519Str(toPollFrom.pubkey_ed25519)} namespaces: ${namespaces} returned: ${resultsFromAllNamespaces?.length}`
);
} catch (e) {
window.log.warn(
`pollNodeForKey of ${pubkey} namespaces: ${namespaces} failed with: ${e.message}`
@ -475,6 +484,9 @@ export class SwarmPolling {
return last(r.messages.messages);
});
window.log.info(
`updating last hashes for ${ed25519Str(pubkey.key)}: ${ed25519Str(snodeEdkey)} ${lastMessages.map(m => m?.hash || '')}`
);
await Promise.all(
lastMessages.map(async (lastMessage, index) => {
if (!lastMessage) {

Loading…
Cancel
Save