File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
packages/javascript/tests Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,25 @@ describe('beforeSend', () => {
142142 ) ;
143143 } ) ;
144144
145+ it ( 'should still send event when structuredClone throws (non-cloneable payload)' , async ( ) => {
146+ // Arrange
147+ const { sendSpy, transport } = createTransport ( ) ;
148+ const hawk = createCatcher ( transport , ( event ) => event ) ;
149+ const cloneSpy = vi . spyOn ( globalThis , 'structuredClone' ) . mockImplementation ( ( ) => {
150+ throw new DOMException ( 'could not be cloned' , 'DataCloneError' ) ;
151+ } ) ;
152+
153+ // Act
154+ hawk . send ( new Error ( 'non-cloneable' ) ) ;
155+ await wait ( ) ;
156+
157+ // Assert — event is still sent, reporting didn't crash
158+ expect ( sendSpy ) . toHaveBeenCalledOnce ( ) ;
159+ expect ( getSentPayload ( sendSpy ) ! . title ) . toBe ( 'non-cloneable' ) ;
160+
161+ cloneSpy . mockRestore ( ) ;
162+ } ) ;
163+
145164 it ( 'should send event without deleted optional fields' , async ( ) => {
146165 // Arrange
147166 const { sendSpy, transport } = createTransport ( ) ;
You can’t perform that action at this time.
0 commit comments