Skip to content

Commit fd69ca8

Browse files
committed
Fixed an issue where the dedup plugin would return and not call the next callback
@srijken plugins can’t have returns unless they call the next callback. This has also bitten me
1 parent 7b6f800 commit fd69ca8

8 files changed

+74
-79
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"files.insertFinalNewline": true
3+
"files.insertFinalNewline": true,
4+
"typescript.tsdk": "./node_modules/typescript/lib"
45
}

dist/exceptionless.js

+22-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js

+22-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/default/DuplicateCheckerPlugin.ts

+24-28
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class DuplicateCheckerPlugin implements IEventPlugin {
2626
public run(context: EventPluginContext, next?: () => void): void {
2727
function getHashCode(error: IInnerError): number {
2828
let hashCode = 0;
29-
3029
while (error) {
3130
if (error.message && error.message.length) {
3231
hashCode += (hashCode * 397) ^ Utils.getHashCode(error.message);
@@ -42,36 +41,33 @@ export class DuplicateCheckerPlugin implements IEventPlugin {
4241

4342
let error = context.event.data['@error'];
4443
let hashCode = getHashCode(error);
44+
if (hashCode) {
45+
let count = context.event.count || 1;
46+
let now = this._getCurrentTime();
47+
48+
let merged = this._mergedEvents.filter(s => s.hashCode === hashCode)[0];
49+
if (merged) {
50+
merged.incrementCount(count);
51+
merged.updateDate(context.event.date);
52+
context.log.info('Ignoring duplicate event with hash: ' + hashCode);
53+
context.cancelled = true;
54+
}
4555

46-
if (!hashCode) {
47-
return;
48-
}
49-
50-
let count = context.event.count || 1;
51-
let now = this._getCurrentTime();
52-
53-
let merged = this._mergedEvents.filter(s => s.hashCode === hashCode)[0];
54-
if (merged) {
55-
merged.incrementCount(count);
56-
merged.updateDate(context.event.date);
57-
context.log.info('Ignoring duplicate event with hash: ' + hashCode);
58-
context.cancelled = true;
59-
return;
60-
}
61-
62-
if (this._processedHashcodes.some(h => h.hash === hashCode && h.timestamp >= (now - this._interval))) {
63-
context.log.trace('Adding event with hash: ' + hashCode);
64-
this._mergedEvents.push(new MergedEvent(hashCode, context, count));
65-
context.cancelled = true;
66-
return;
67-
}
56+
if (!context.cancelled && this._processedHashcodes.some(h => h.hash === hashCode && h.timestamp >= (now - this._interval))) {
57+
context.log.trace('Adding event with hash: ' + hashCode);
58+
this._mergedEvents.push(new MergedEvent(hashCode, context, count));
59+
context.cancelled = true;
60+
}
6861

69-
context.log.trace('Enqueueing event with hash: ' + hashCode + 'to cache.');
70-
this._processedHashcodes.push({ hash: hashCode, timestamp: now });
62+
if (!context.cancelled) {
63+
context.log.trace('Enqueueing event with hash: ' + hashCode + 'to cache.');
64+
this._processedHashcodes.push({ hash: hashCode, timestamp: now });
7165

72-
// Only keep the last 50 recent errors.
73-
while (this._processedHashcodes.length > 50) {
74-
this._processedHashcodes.shift();
66+
// Only keep the last 50 recent errors.
67+
while (this._processedHashcodes.length > 50) {
68+
this._processedHashcodes.shift();
69+
}
70+
}
7571
}
7672

7773
next && next();

0 commit comments

Comments
 (0)