Skip to content

Commit d25f85e

Browse files
committed
fix(JingleSessionPC) Ignore XMPP responses if peer has terminated the session.
Before, code was getting the children of the <iq> element, which would just return the <error> element and not children of the <error> element, which includes <item-not-found>, etc. Fixes an issue where local source is removed because the source-add sent to the p2p peer gets rejected because of a 3rd endpoint joining the call resulting in the p2p session getting terminated.
1 parent 78e345f commit d25f85e

File tree

1 file changed

+21
-35
lines changed

1 file changed

+21
-35
lines changed

modules/xmpp/JingleSessionPC.ts

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { SDPDiffer } from '../sdp/SDPDiffer';
2222
import SDPUtil from '../sdp/SDPUtil';
2323
import Statistics from '../statistics/statistics';
2424
import AsyncQueue, { ClearedQueueError } from '../util/AsyncQueue';
25-
import { exists, findAll, findFirst, getAttribute, getText } from '../util/XMLUtils';
25+
import { exists, findAll, findFirst, getAttribute } from '../util/XMLUtils';
2626

2727
import JingleSession from './JingleSession';
2828
import { JingleSessionState } from './JingleSessionState';
@@ -1049,19 +1049,6 @@ export default class JingleSessionPC extends JingleSession {
10491049
*/
10501050
private newJingleErrorHandler(failureCb?: (error: IJingleError) => void): ErrorCallback {
10511051
return errResponse => {
1052-
1053-
// Call handleStropheError for centralized error logging and analytics
1054-
handleStropheError(errResponse, {
1055-
isP2P: this.isP2P,
1056-
operation: 'Jingle IQ',
1057-
remoteJid: this.remoteJid,
1058-
roomJid: this.room?.roomjid,
1059-
session: this.toString(),
1060-
sid: this.sid,
1061-
state: this.state,
1062-
userJid: this.connection.jid
1063-
});
1064-
10651052
const error: IJingleError = {
10661053
code: undefined,
10671054
msg: undefined,
@@ -1075,38 +1062,37 @@ export default class JingleSessionPC extends JingleSession {
10751062

10761063
if (errorElSel) {
10771064
error.code = getAttribute(errorElSel, 'code');
1078-
const errorResponseChildren = errResponse.children;
1065+
const errorResponseChildren = errorElSel.children;
10791066

10801067
if (errorResponseChildren.length) {
10811068
error.reason = errorResponseChildren[0].tagName;
10821069
}
1083-
1084-
const errorMsgSel = findFirst(errorElSel, ':scope>text');
1085-
1086-
if (errorMsgSel) {
1087-
error.msg = getText(errorMsgSel);
1088-
}
10891070
}
10901071
}
10911072

10921073
if (!errResponse) {
10931074
error.reason = 'timeout';
10941075
}
10951076

1096-
error.session = this.toString();
1097-
1098-
if (failureCb) {
1099-
failureCb(error);
1100-
} else if (this.state === JingleSessionState.ENDED
1101-
&& error.reason === 'item-not-found') {
1102-
// When remote peer decides to terminate the session, but it
1103-
// still have few messages on the queue for processing,
1104-
// it will first send us 'session-terminate' (we enter ENDED)
1105-
// and then follow with 'item-not-found' for the queued requests
1106-
// We don't want to have that logged on error level.
1107-
logger.debug(`${this} Jingle error: ${JSON.stringify(error)}`);
1108-
} else {
1109-
logger.error(`Jingle error: ${JSON.stringify(error)}`);
1077+
// When remote peer decides to terminate the session, but it still has few messages on the queue for
1078+
// processing, it will first send us 'session-terminate' (we enter ENDED) and then follow with
1079+
// 'item-not-found' for the queued requests. These 'item-not-found' errors can be ignored.
1080+
const ignoreErrors = this.state === JingleSessionState.ENDED && error?.reason === 'item-not-found';
1081+
1082+
if (!ignoreErrors) {
1083+
failureCb?.(error);
1084+
1085+
// Call handleStropheError for centralized error logging and analytics.
1086+
handleStropheError(errResponse, {
1087+
isP2P: this.isP2P,
1088+
operation: 'Jingle IQ',
1089+
remoteJid: this.remoteJid,
1090+
roomJid: this.room?.roomjid,
1091+
session: this.toString(),
1092+
sid: this.sid,
1093+
state: this.state,
1094+
userJid: this.connection.jid
1095+
});
11101096
}
11111097
};
11121098
}

0 commit comments

Comments
 (0)