@@ -5,7 +5,9 @@ import * as SentryUtils from '@sentry/utils';
5
5
import type { Replay } from '../../src' ;
6
6
import type { ReplayContainer } from '../../src/replay' ;
7
7
import { clearSession } from '../../src/session/clearSession' ;
8
- import type { EventType } from '../../src/types' ;
8
+ import type { BreadcrumbFrame , EventType } from '../../src/types' ;
9
+ import { createPerformanceEntries } from '../../src/util/createPerformanceEntries' ;
10
+ import { createPerformanceSpans } from '../../src/util/createPerformanceSpans' ;
9
11
import * as SendReplayRequest from '../../src/util/sendReplayRequest' ;
10
12
import { BASE_TIMESTAMP , mockRrweb , mockSdk } from '../index' ;
11
13
import { useFakeTimers } from '../utils/use-fake-timers' ;
@@ -40,6 +42,10 @@ describe('Integration | beforeAddRecordingEvent', () => {
40
42
beforeAddRecordingEvent : event => {
41
43
const eventData = event . data ;
42
44
45
+ if ( eventData . tag === 'performanceSpan' ) {
46
+ throw new Error ( 'test error in callback' ) ;
47
+ }
48
+
43
49
if ( eventData . tag === 'breadcrumb' && eventData . payload . category === 'ui.click' ) {
44
50
return {
45
51
...event ,
@@ -53,12 +59,6 @@ describe('Integration | beforeAddRecordingEvent', () => {
53
59
} ;
54
60
}
55
61
56
- // This should not do anything because callback should not be called
57
- // for `event.type != 5` - but we guard anyhow to be safe
58
- if ( ( event . type as EventType ) === 2 ) {
59
- return null ;
60
- }
61
-
62
62
if ( eventData . tag === 'options' ) {
63
63
return null ;
64
64
}
@@ -143,4 +143,42 @@ describe('Integration | beforeAddRecordingEvent', () => {
143
143
recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP , type : 2 } ] ) ,
144
144
} ) ;
145
145
} ) ;
146
+
147
+ it ( 'handles error in callback' , async ( ) => {
148
+ createPerformanceSpans (
149
+ replay ,
150
+ createPerformanceEntries ( [
151
+ {
152
+ name : 'https://sentry.io/foo.js' ,
153
+ entryType : 'resource' ,
154
+ startTime : 176.59999990463257 ,
155
+ duration : 5.600000023841858 ,
156
+ initiatorType : 'link' ,
157
+ nextHopProtocol : 'h2' ,
158
+ workerStart : 177.5 ,
159
+ redirectStart : 0 ,
160
+ redirectEnd : 0 ,
161
+ fetchStart : 177.69999992847443 ,
162
+ domainLookupStart : 177.69999992847443 ,
163
+ domainLookupEnd : 177.69999992847443 ,
164
+ connectStart : 177.69999992847443 ,
165
+ connectEnd : 177.69999992847443 ,
166
+ secureConnectionStart : 177.69999992847443 ,
167
+ requestStart : 177.5 ,
168
+ responseStart : 181 ,
169
+ responseEnd : 182.19999992847443 ,
170
+ transferSize : 0 ,
171
+ encodedBodySize : 0 ,
172
+ decodedBodySize : 0 ,
173
+ serverTiming : [ ] ,
174
+ } as unknown as PerformanceResourceTiming ,
175
+ ] ) ,
176
+ ) ;
177
+
178
+ jest . runAllTimers ( ) ;
179
+ await new Promise ( process . nextTick ) ;
180
+
181
+ expect ( replay ) . not . toHaveLastSentReplay ( ) ;
182
+ expect ( replay . isEnabled ( ) ) . toBe ( true ) ;
183
+ } ) ;
146
184
} ) ;
0 commit comments