Skip to content

Commit 2934b55

Browse files
committed
remove safeUnsubscribe
1 parent 059e2dc commit 2934b55

File tree

1 file changed

+3
-11
lines changed
  • packages/browser-utils/src/metrics

1 file changed

+3
-11
lines changed

packages/browser-utils/src/metrics/utils.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,13 @@ export function listenForWebVitalReportEvents(
226226
// we only want to collect LCP if we actually navigate. Redirects should be ignored.
227227
if (!options?.isRedirect) {
228228
_runCollectorCallbackOnce('navigation');
229-
safeUnsubscribe(unsubscribeStartNavigation, unsubscribeAfterStartPageLoadSpan);
229+
unsubscribeStartNavigation();
230+
unsubscribeAfterStartPageLoadSpan();
230231
}
231232
});
232233

233234
const unsubscribeAfterStartPageLoadSpan = client.on('afterStartPageLoadSpan', span => {
234235
pageloadSpanId = span.spanContext().spanId;
235-
safeUnsubscribe(unsubscribeAfterStartPageLoadSpan);
236+
unsubscribeAfterStartPageLoadSpan();
236237
});
237238
}
238-
239-
/**
240-
* Invoke a list of unsubscribers in a safe way, by deferring the invocation to the next tick.
241-
* This is necessary because unsubscribing in sync can lead to other callbacks no longer being invoked
242-
* due to in-place array mutation of the subscribers array on the client.
243-
*/
244-
function safeUnsubscribe(...unsubscribers: (() => void | undefined)[]): void {
245-
unsubscribers.forEach(u => u && setTimeout(u, 0));
246-
}

0 commit comments

Comments
 (0)