mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
handle 421 on sending delete_all
This commit is contained in:
parent
32955c9ed5
commit
f75f63e4e9
2 changed files with 14 additions and 2 deletions
|
@ -1,8 +1,14 @@
|
|||
import { default as insecureNodeFetch } from 'node-fetch';
|
||||
import pRetry from 'p-retry';
|
||||
import { Snode } from '../../data/data';
|
||||
import { getStoragePubKey } from '../types';
|
||||
|
||||
import { lokiOnionFetch, snodeHttpsAgent, SnodeResponse } from './onions';
|
||||
import {
|
||||
ERROR_421_HANDLED_RETRY_REQUEST,
|
||||
lokiOnionFetch,
|
||||
snodeHttpsAgent,
|
||||
SnodeResponse,
|
||||
} from './onions';
|
||||
|
||||
interface FetchOptions {
|
||||
method: string;
|
||||
|
@ -81,6 +87,9 @@ async function lokiFetch({
|
|||
if (e.code === 'ENOTFOUND') {
|
||||
throw new window.textsecure.NotFoundError('Failed to resolve address', e);
|
||||
}
|
||||
if (e.message === ERROR_421_HANDLED_RETRY_REQUEST) {
|
||||
throw new pRetry.AbortError(ERROR_421_HANDLED_RETRY_REQUEST);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,6 +494,9 @@ export async function processOnionResponse({
|
|||
}
|
||||
}
|
||||
|
||||
export const ERROR_421_HANDLED_RETRY_REQUEST =
|
||||
'421 handled. Retry this request with a new targetNode';
|
||||
|
||||
export const snodeHttpsAgent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
@ -561,7 +564,7 @@ async function handle421InvalidSwarm({
|
|||
await Onions.incrementBadSnodeCountOrDrop({ snodeEd25519, associatedWith });
|
||||
|
||||
// this is important we throw so another retry is made and we exit the handling of that reponse
|
||||
throw new pRetry.AbortError(exceptionMessage);
|
||||
throw new pRetry.AbortError(ERROR_421_HANDLED_RETRY_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue