Skip to content

Commit c629a0d

Browse files
authored
fix: Check for performance.timing in webworkers (getsentry#2491)
* fix: Check for performance.timing in webworkers * chore: Changelog * fix: Typo * chore: Comment
1 parent b6dd2c7 commit c629a0d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
- [apm] fix: Check for performance.timing in webworkers (#2491)
78
- [apm] ref: Remove performance clear entry calls (#2490)
89

910
## 5.14.0

packages/utils/src/misc.ts

+10
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,16 @@ export const crossPlatformPerformance: Pick<Performance, 'now' | 'timeOrigin'> =
378378
// is not as widely supported. Namely, performance.timeOrigin is undefined in Safari as of writing.
379379
// tslint:disable-next-line:strict-type-predicates
380380
if (performance.timeOrigin === undefined) {
381+
// For webworkers it could mean we don't have performance.timing then we fallback
382+
// tslint:disable-next-line:deprecation
383+
if (!performance.timing) {
384+
return performanceFallback;
385+
}
386+
// tslint:disable-next-line:deprecation
387+
if (!performance.timing.navigationStart) {
388+
return performanceFallback;
389+
}
390+
381391
// @ts-ignore
382392
// tslint:disable-next-line:deprecation
383393
performance.timeOrigin = performance.timing.navigationStart;

0 commit comments

Comments
 (0)