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