Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(base/conference): leave a failed conference

paweldomas965040409926
diff --git a/react/features/base/conference/middleware.js b/react/features/base/conference/middleware.js
index 770d06fbd8..973bcd707f 100644
--- a/react/features/base/conference/middleware.js
+++ b/react/features/base/conference/middleware.js
@@ -26,6 +26,7 @@ import {
toggleAudioOnly
} from './actions';
import {
+ CONFERENCE_FAILED,
CONFERENCE_JOINED,
DATA_CHANNEL_OPENED,
SET_AUDIO_ONLY,
@@ -55,6 +56,9 @@ MiddlewareRegistry.register(store => next => action => {
case CONNECTION_ESTABLISHED:
return _connectionEstablished(store, next, action);
+ case CONFERENCE_FAILED:
+ return _conferenceFailed(next, action);
+
case CONFERENCE_JOINED:
return _conferenceJoined(store, next, action);
@@ -109,6 +113,33 @@ function _connectionEstablished({ dispatch }, next, action) {
return result;
}
+/**
+ * Makes sure to leave a failed conference in order to release any allocated
+ * resources like peerconnections, emit participant left events etc.
+ *
+ * @param {Dispatch} next - The redux dispatch function to dispatch the
+ * specified action to the specified store.
+ * @param {Action} action - The redux action CONFERENCE_FAILED which is being
+ * dispatched in the specified store.
+ * @private
+ * @returns {Object} The value returned by {@code next(action)}.
+ */
+function _conferenceFailed(next, action) {
+ const result = next(action);
+ const { conference, error } = action;
+
+ !error.recoverable
+ && conference
+ && conference.leave().catch(leaveError => {
+ // Even though we don't care too much about the failure it may be
+ // good to now that it happen, so log it on the info level.
+ logger.info(
+ 'There was an error leaving a failed conference: ', leaveError);
+ });
+
+ return result;
+}
+
/**
* Does extra sync up on properties that may need to be updated after the
* conference was joined.