Skip to content

Commit 8fe0531

Browse files
committed
Return undefined so we don't allocate
1 parent d054af5 commit 8fe0531

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/core/src/utils/prepareEvent.ts

+4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ export function applyDebugIds(event: Event, stackParser: StackParser): void {
174174
// Build a map of filename -> debug_id
175175
const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
176176

177+
if (!filenameDebugIdMap) {
178+
return;
179+
}
180+
177181
try {
178182
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
179183
event!.exception!.values!.forEach(exception => {

packages/utils/src/debug-ids.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ let cachedFilenameToDebugId: Map<string, string> | undefined;
3131
/**
3232
* Returns a map of filenames to debug identifiers.
3333
*/
34-
export function getFilenameToDebugIdMap(stackParser: StackParser): Map<string, string> {
34+
export function getFilenameToDebugIdMap(stackParser: StackParser): Map<string, string> | undefined {
3535
const debugIdMap = GLOBAL_OBJ._sentryDebugIds;
3636
if (!debugIdMap) {
37-
return new Map();
37+
return undefined;
3838
}
3939

4040
const debugIdKeys = Object.keys(debugIdMap);
@@ -89,6 +89,10 @@ export function getDebugImagesForResources(
8989
): DebugImage[] {
9090
const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
9191

92+
if (!filenameDebugIdMap) {
93+
return [];
94+
}
95+
9296
const images: DebugImage[] = [];
9397
for (const path of resource_paths) {
9498
const debug_id = filenameDebugIdMap.get(path);

0 commit comments

Comments
 (0)