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

Commit

Permalink
Catch TypeError thrown by Safari if invalid entryType passed (#167)
Browse files Browse the repository at this point in the history
Closes #166
  • Loading branch information
backjo authored and draffensperger committed Aug 22, 2019
1 parent d1a0c11 commit 2818dee
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ export function recordLongTasks() {
const longTaskObserver = new windowWithLongTasks.PerformanceObserver(
onLongTasks
);
longTaskObserver.observe({ entryTypes: ['longtask'] });
try {
longTaskObserver.observe({ entryTypes: ['longtask'] });
} catch (err) {
//Safari (at least) throws a TypeError if entryTypes does not contain a valid entry.
//This can block further script execution. Gracefully handle this error and log instead.
console.error(err);
}
}
windowWithLongTasks.ocLt = [];
}
Expand Down

0 comments on commit 2818dee

Please sign in to comment.