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: locus DTOs not handled if an earlier one causes an error #3982

Merged
merged 3 commits into from
Nov 18, 2024
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
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
);
marcin-bazyl marked this conversation as resolved.
Show resolved Hide resolved
}
},

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
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
Loading