Skip to content

Commit

Permalink
fix: locus DTOs not handled if an earlier one causes an error (#3982)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-bazyl authored Nov 18, 2024
1 parent ddaab3e commit 52fb49e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
8 changes: 5 additions & 3 deletions packages/@webex/internal-plugin-mercury/src/mercury.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,12 @@ const Mercury = WebexPlugin.extend({
try {
this.trigger(...args);
} catch (error) {
this.logger.error(`${this.namespace}: error occurred in event handler`, {
this.logger.error(
`${this.namespace}: error occurred in event handler:`,
error,
arguments: args,
});
' with args: ',
args
);
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,13 @@ describe('plugin-mercury', () => {
sinon.stub(mercury.logger, 'error');

return Promise.resolve(mercury._emit('break', event)).then((res) => {
assert.calledWith(mercury.logger.error, 'Mercury: error occurred in event handler', {
assert.calledWith(
mercury.logger.error,
'Mercury: error occurred in event handler:',
error,
arguments: ['break', event],
});
' with args: ',
['break', event]
);
return res;
});
});
Expand Down
9 changes: 8 additions & 1 deletion packages/@webex/plugin-meetings/src/locus-info/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,14 @@ export default class Parser {
)}, Action: ${lociComparison}`
);

this.onDeltaAction(lociComparison, newLoci);
try {
this.onDeltaAction(lociComparison, newLoci);
} catch (error) {
LoggerProxy.logger.error(
'Locus-info:parser#processDeltaEvent --> Error in onDeltaAction',
error
);
}
}

this.nextEvent();
Expand Down
29 changes: 29 additions & 0 deletions packages/@webex/plugin-meetings/test/unit/spec/locus-info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,35 @@ describe('plugin-meetings', () => {
assert.calledWith(locusInfo.applyLocusDeltaData, action, parsedLoci, fakeMeeting);
});

it('catches errors thrown by onDeltaAction and is able to process next Locus delta', () => {
const fakeLocusDelta = {
sequence: {
rangeStart: 0,
rangeEnd: 0,
},
};
locusInfo.locusParser.workingCopy = {
sequence: {
rangeStart: 0,
rangeEnd: 0,
},
};
const testMeeting = {locusInfo: {onDeltaLocus: sinon.stub()}};

locusParser.onDeltaAction = sandbox
.stub()
.onCall(0)
.callsFake(() => {
throw new Error('fake error');
});

// simulate first locus delta coming - it will trigger an error thrown by onDeltaAction
locusInfo.handleLocusDelta(fakeLocusDelta, testMeeting);

// simulate a second locus delta coming - it should be processed without errors
locusInfo.handleLocusDelta(fakeLocusDelta, testMeeting);
});

it('applyLocusDeltaData handles USE_INCOMING action correctly', () => {
const {USE_INCOMING} = LocusDeltaParser.loci;
const meeting = {
Expand Down

0 comments on commit 52fb49e

Please sign in to comment.