Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 2818dee

Browse files
backjodraffensperger
authored andcommitted
Catch TypeError thrown by Safari if invalid entryType passed (#167)
Closes #166
1 parent d1a0c11 commit 2818dee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/opencensus-web-instrumentation-perf/src/long-tasks-recorder.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ export function recordLongTasks() {
3333
const longTaskObserver = new windowWithLongTasks.PerformanceObserver(
3434
onLongTasks
3535
);
36-
longTaskObserver.observe({ entryTypes: ['longtask'] });
36+
try {
37+
longTaskObserver.observe({ entryTypes: ['longtask'] });
38+
} catch (err) {
39+
//Safari (at least) throws a TypeError if entryTypes does not contain a valid entry.
40+
//This can block further script execution. Gracefully handle this error and log instead.
41+
console.error(err);
42+
}
3743
}
3844
windowWithLongTasks.ocLt = [];
3945
}

0 commit comments

Comments
 (0)