Skip to content

Commit 6c9a7a5

Browse files
author
Hardik Choksi
committed
Remove duplicate event prevention from addExceptionEvent function
1 parent 07d05cc commit 6c9a7a5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/exception-handler.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const fs = require("fs");
44
const { trace, SpanStatusCode } = require("@opentelemetry/api");
55
const ErrorStackParser = require("error-stack-parser");
66

7-
let hasException = false; // Track if an exception has already been processed
8-
97
/**
108
* Check if file is external (node_modules, etc.)
119
* @param {string} filePath - The file path
@@ -169,7 +167,7 @@ function findContainingFunction(lines, targetLine) {
169167
*/
170168
function createExceptionSpanEvent(error) {
171169
const span = trace.getActiveSpan();
172-
170+
173171
if (!span) {
174172
// Create a new span if none is active
175173
const tracer = trace.getTracer("@middleware.io/agent-apm-nextjs");
@@ -191,8 +189,6 @@ function createExceptionSpanEvent(error) {
191189
* @param {Error} error - The error object
192190
*/
193191
function addExceptionEvent(span, error) {
194-
if (hasException) return; // Prevent duplicate events
195-
hasException = true;
196192
// Add function context information
197193
const structuredStack = jsonToString(ErrorStackParser.parse(error));
198194

0 commit comments

Comments
 (0)