Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GlobalOnErrorHandler) avoid calling it when we handle the error #2411

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import AvgRTPStatsReporter from './modules/statistics/AvgRTPStatsReporter';
import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
import SpeakerStatsCollector from './modules/statistics/SpeakerStatsCollector';
import Statistics from './modules/statistics/statistics';
import GlobalOnErrorHandler from './modules/util/GlobalOnErrorHandler';
import { safeSubtract } from './modules/util/MathUtil';
import RandomUtil from './modules/util/RandomUtil';
import ComponentsVersions from './modules/version/ComponentsVersions';
Expand Down Expand Up @@ -2195,7 +2194,6 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(jingleSession, jingl
enableInsertableStreams: this.isE2EEEnabled() || FeatureFlags.isRunInLiteModeEnabled()
});
} catch (error) {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error(error);

return;
Expand Down Expand Up @@ -2223,7 +2221,6 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(jingleSession, jingl
}
},
error => {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error('Failed to accept incoming Jingle session', error);
},
localTracks
Expand All @@ -2235,7 +2232,6 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(jingleSession, jingl

this.statistics.startRemoteStats(this.jvbJingleSession.peerconnection);
} catch (e) {
GlobalOnErrorHandler.callErrorHandler(e);
logger.error(e);
}
};
Expand Down
24 changes: 0 additions & 24 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import recordingConstants from './modules/recording/recordingConstants';
import Settings from './modules/settings/Settings';
import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
import Statistics from './modules/statistics/statistics';
import GlobalOnErrorHandler from './modules/util/GlobalOnErrorHandler';
import ScriptUtil from './modules/util/ScriptUtil';
import * as VideoSIPGWConstants from './modules/videosipgw/VideoSIPGWConstants';
import AudioMixer from './modules/webaudio/AudioMixer';
Expand Down Expand Up @@ -165,11 +164,6 @@ export default {
this.analytics.dispose();
}

if (options.enableWindowOnErrorHandler) {
GlobalOnErrorHandler.addHandler(
this.getGlobalOnErrorHandler.bind(this));
}

return RTC.init(options);
},

Expand Down Expand Up @@ -556,24 +550,6 @@ export default {
this.mediaDevices.enumerateDevices(callback);
},

/* eslint-disable max-params */

/**
* @returns function that can be used to be attached to window.onerror and
* if options.enableWindowOnErrorHandler is enabled returns
* the function used by the lib.
* (function(message, source, lineno, colno, error)).
*/
getGlobalOnErrorHandler(message, source, lineno, colno, error) {
logger.error(
`UnhandledError: ${message}`,
`Script: ${source}`,
`Line: ${lineno}`,
`Column: ${colno}`,
'StackTrace: ', error);
},
/* eslint-enable max-params */

/**
* Informs lib-jitsi-meet about the current network status.
*
Expand Down
2 changes: 0 additions & 2 deletions modules/RTC/BridgeChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getLogger } from '@jitsi/logger';
import RTCEvents from '../../service/RTC/RTCEvents';
import { createBridgeChannelClosedEvent } from '../../service/statistics/AnalyticsEvents';
import Statistics from '../statistics/statistics';
import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';

const logger = getLogger(__filename);

Expand Down Expand Up @@ -295,7 +294,6 @@ export default class BridgeChannel {
try {
obj = safeJsonParse(data);
} catch (error) {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error('Failed to parse channel message as JSON: ', data, error);

return;
Expand Down
2 changes: 0 additions & 2 deletions modules/RTC/RTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
import { MediaType } from '../../service/RTC/MediaType';
import RTCEvents from '../../service/RTC/RTCEvents';
import browser from '../browser';
import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
import Listenable from '../util/Listenable';
import { safeCounterIncrement } from '../util/MathUtil';

Expand Down Expand Up @@ -198,7 +197,6 @@ export default class RTC extends Listenable {

this._channelOpenListener = () => {
const logError = (error, msgType, value) => {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error(`Cannot send ${msgType}(${JSON.stringify(value)}) endpoint message`, error);
};

Expand Down
8 changes: 1 addition & 7 deletions modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { VideoType } from '../../service/RTC/VideoType';
import { AVAILABLE_DEVICE } from '../../service/statistics/AnalyticsEvents';
import browser from '../browser';
import Statistics from '../statistics/statistics';
import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
import Listenable from '../util/Listenable';

import screenObtainer from './ScreenObtainer';
Expand Down Expand Up @@ -873,15 +872,10 @@ function wrapAttachMediaStream(origAttachMediaStream) {

// we skip setting audio output if there was no explicit change
&& audioOutputChanged) {
return element.setSinkId(rtcUtils.getAudioOutputDevice()).catch(function(ex) {
return element.setSinkId(rtcUtils.getAudioOutputDevice()).catch(ex => {
const err
= new JitsiTrackError(ex, null, [ 'audiooutput' ]);

GlobalOnErrorHandler.callUnhandledRejectionHandler({
promise: this, // eslint-disable-line no-invalid-this
reason: err
});

logger.warn(
'Failed to set audio output device for the element.'
+ ' Default audio output device will be used'
Expand Down
30 changes: 12 additions & 18 deletions modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import SDPUtil from '../sdp/SDPUtil';
import SdpConsistency from '../sdp/SdpConsistency';
import SdpSimulcast from '../sdp/SdpSimulcast';
import { SdpTransformWrap } from '../sdp/SdpTransformUtil';
import * as GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';

import JitsiRemoteTrack from './JitsiRemoteTrack';
import RTC from './RTC';
Expand Down Expand Up @@ -959,8 +958,7 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track, tr

// look up an associated JID for a stream id
if (!mediaType) {
GlobalOnErrorHandler.callErrorHandler(
new Error(`MediaType undefined for remote track, stream id: ${streamId}, track creation failed!`));
logger.error(`MediaType undefined for remote track, stream id: ${streamId}, track creation failed!`);

return;
}
Expand Down Expand Up @@ -988,9 +986,8 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track, tr
}

if (!mediaLine) {
GlobalOnErrorHandler.callErrorHandler(
new Error(`Matching media line not found in remote SDP for remote stream[id=${streamId},type=${mediaType}],`
+ 'track creation failed!'));
logger.error(`Matching media line not found in remote SDP for remote stream[id=${streamId},type=${mediaType}],`
+ 'track creation failed!');

return;
}
Expand All @@ -999,9 +996,8 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track, tr

ssrcLines = ssrcLines.filter(line => line.indexOf(`msid:${streamId}`) !== -1);
if (!ssrcLines.length) {
GlobalOnErrorHandler.callErrorHandler(
new Error(`No SSRC lines found in remote SDP for remote stream[msid=${streamId},type=${mediaType}]`
+ 'track creation failed!'));
logger.error(`No SSRC lines found in remote SDP for remote stream[msid=${streamId},type=${mediaType}]`
+ 'track creation failed!');

return;
}
Expand All @@ -1013,17 +1009,15 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track, tr
const ownerEndpointId = this.signalingLayer.getSSRCOwner(trackSsrc);

if (isNaN(trackSsrc) || trackSsrc < 0) {
GlobalOnErrorHandler.callErrorHandler(
new Error(`Invalid SSRC for remote stream[ssrc=${trackSsrc},id=${streamId},type=${mediaType}]`
+ 'track creation failed!'));
logger.error(`Invalid SSRC for remote stream[ssrc=${trackSsrc},id=${streamId},type=${mediaType}]`
+ 'track creation failed!');

return;
}

if (!ownerEndpointId) {
GlobalOnErrorHandler.callErrorHandler(
new Error(`No SSRC owner known for remote stream[ssrc=${trackSsrc},id=${streamId},type=${mediaType}]`
+ 'track creation failed!'));
logger.error(`No SSRC owner known for remote stream[ssrc=${trackSsrc},id=${streamId},type=${mediaType}]`
+ 'track creation failed!');

return;
}
Expand Down Expand Up @@ -1152,13 +1146,13 @@ TraceablePeerConnection.prototype._remoteTrackRemoved = function(stream, track)
}

if (!streamId) {
GlobalOnErrorHandler.callErrorHandler(new Error(`${this} remote track removal failed - no stream ID`));
logger.error(`${this} remote track removal failed - no stream ID`);

return;
}

if (!trackId) {
GlobalOnErrorHandler.callErrorHandler(new Error(`${this} remote track removal failed - no track ID`));
logger.error(`${this} remote track removal failed - no track ID`);

return;
}
Expand All @@ -1167,7 +1161,7 @@ TraceablePeerConnection.prototype._remoteTrackRemoved = function(stream, track)
remoteTrack => remoteTrack.getStreamId() === streamId && remoteTrack.getTrackId() === trackId);

if (!toBeRemoved) {
GlobalOnErrorHandler.callErrorHandler(new Error(`${this} remote track removal failed - track not found`));
logger.error(`${this} remote track removal failed - track not found`);

return;
}
Expand Down
4 changes: 0 additions & 4 deletions modules/statistics/RTPStatsCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import * as StatisticsEvents from '../../service/statistics/Events';
import browser from '../browser';
import FeatureFlags from '../flags/FeatureFlags';

const GlobalOnErrorHandler = require('../util/GlobalOnErrorHandler');

const logger = getLogger(__filename);

/**
Expand Down Expand Up @@ -185,7 +183,6 @@ StatsCollector.prototype.stop = function() {
* @param error an error that occurred on <tt>getStats</tt> call.
*/
StatsCollector.prototype.errorCallback = function(error) {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error('Get stats error', error);
this.stop();
};
Expand Down Expand Up @@ -228,7 +225,6 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
try {
this.processStatsReport();
} catch (error) {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error('Processing of RTP stats failed:', error);
}
this.previousStatsReport = this.currentStatsReport;
Expand Down
79 changes: 0 additions & 79 deletions modules/util/GlobalOnErrorHandler.js

This file was deleted.

9 changes: 1 addition & 8 deletions modules/xmpp/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import AuthenticationEvents from '../../service/authentication/AuthenticationEve
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
import Settings from '../settings/Settings';
import EventEmitterForwarder from '../util/EventEmitterForwarder';
import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
import Listenable from '../util/Listenable';

import AVModeration from './AVModeration';
Expand Down Expand Up @@ -404,7 +403,6 @@ export default class ChatRoom extends Listenable {
}
}
}, error => {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error('Error getting room info: ', error);
});
}
Expand Down Expand Up @@ -445,10 +443,7 @@ export default class ChatRoom extends Listenable {
if (!$(form).find(
'>query>x[xmlns="jabber:x:data"]'
+ '>field[var="muc#roomconfig_whois"]').length) {
const errmsg = 'non-anonymous rooms not supported';

GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
logger.error(errmsg);
logger.error('non-anonymous rooms not supported');

return;
}
Expand All @@ -470,7 +465,6 @@ export default class ChatRoom extends Listenable {
this.connection.sendIQ(formSubmit);

}, error => {
GlobalOnErrorHandler.callErrorHandler(error);
logger.error('Error getting room configuration form: ', error);
});
}
Expand Down Expand Up @@ -895,7 +889,6 @@ export default class ChatRoom extends Listenable {
});
}
} catch (e) {
GlobalOnErrorHandler.callErrorHandler(e);
logger.error(`Error processing:${node.tagName} node.`, e);
}
}
Expand Down
Loading