Calling/handleOutgoingSignaling: Wait for job completion or timeout
This commit is contained in:
@@ -158,6 +158,7 @@ import { getColorForCallLink } from '../util/getColorForCallLink';
|
|||||||
import { getUseRingrtcAdm } from '../util/ringrtc/ringrtcAdm';
|
import { getUseRingrtcAdm } from '../util/ringrtc/ringrtcAdm';
|
||||||
import OS from '../util/os/osMain';
|
import OS from '../util/os/osMain';
|
||||||
import { isLowerHandSuggestionEnabled } from '../util/isLowerHandSuggestionEnabled';
|
import { isLowerHandSuggestionEnabled } from '../util/isLowerHandSuggestionEnabled';
|
||||||
|
import { sleep } from '../util/sleep';
|
||||||
|
|
||||||
const { wasGroupCallRingPreviouslyCanceled } = DataReader;
|
const { wasGroupCallRingPreviouslyCanceled } = DataReader;
|
||||||
const {
|
const {
|
||||||
@@ -176,6 +177,7 @@ const RINGRTC_HTTP_METHOD_TO_OUR_HTTP_METHOD: Map<
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const CLEAN_EXPIRED_GROUP_CALL_RINGS_INTERVAL = 10 * durations.MINUTE;
|
const CLEAN_EXPIRED_GROUP_CALL_RINGS_INTERVAL = 10 * durations.MINUTE;
|
||||||
|
const OUTGOING_SIGNALING_WAIT = 15 * durations.SECOND;
|
||||||
|
|
||||||
const ICE_SERVER_IS_IP_LIKE = /(turn|turns|stun):[.\d]+/;
|
const ICE_SERVER_IS_IP_LIKE = /(turn|turns|stun):[.\d]+/;
|
||||||
const MAX_CALL_DEBUG_STATS_TABS = 5;
|
const MAX_CALL_DEBUG_STATS_TABS = 5;
|
||||||
@@ -2901,18 +2903,24 @@ export class CallingClass {
|
|||||||
const protoBytes = Proto.CallMessage.encode(proto).finish();
|
const protoBytes = Proto.CallMessage.encode(proto).finish();
|
||||||
const protoBase64 = Bytes.toBase64(protoBytes);
|
const protoBase64 = Bytes.toBase64(protoBytes);
|
||||||
|
|
||||||
await conversationJobQueue.add({
|
const job = await conversationJobQueue.add({
|
||||||
type: 'CallingMessage',
|
type: 'CallingMessage',
|
||||||
conversationId: conversation.id,
|
conversationId: conversation.id,
|
||||||
protoBase64,
|
protoBase64,
|
||||||
urgent,
|
urgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const failAfterTimeout = async () => {
|
||||||
|
await sleep(OUTGOING_SIGNALING_WAIT);
|
||||||
|
throw new Error('Ran out of time');
|
||||||
|
};
|
||||||
|
await Promise.race([job.completion, failAfterTimeout()]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errorString = Errors.toLogFormat(err);
|
const errorString = Errors.toLogFormat(err);
|
||||||
log.error(
|
log.error(
|
||||||
`handleOutgoingSignaling() failed to queue job: ${errorString}`
|
`handleOutgoingSignaling() failed to queue job or send: ${errorString}`
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user