File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,6 +161,27 @@ describe('beforeSend processing', () => {
161161 expect ( payload . backtrace ) . toBeInstanceOf ( Array ) ;
162162 } ) ;
163163
164+ it ( 'still sends event when structuredClone throws (non-cloneable payload)' , ( ) => {
165+ // Arrange
166+ initWithBeforeSend ( ( event ) => event ) ;
167+ const cloneSpy = vi . spyOn ( globalThis , 'structuredClone' ) . mockImplementation ( ( ) => {
168+ throw new DOMException ( 'could not be cloned' , 'DataCloneError' ) ;
169+ } ) ;
170+
171+ // Act
172+ HawkCatcher . send ( new Error ( 'non-cloneable' ) ) ;
173+
174+ // Assert — event is still sent, reporting didn't crash
175+ expect ( axios . post ) . toHaveBeenCalledOnce ( ) ;
176+
177+ const payload = getSentPayload ( ) ;
178+
179+ expect ( payload . title ) . toBe ( 'Error: non-cloneable' ) ;
180+ expect ( payload . backtrace ) . toBeInstanceOf ( Array ) ;
181+
182+ cloneSpy . mockRestore ( ) ;
183+ } ) ;
184+
164185 it ( 'sends event without optional fields when beforeSend deletes them' , ( ) => {
165186 initWithBeforeSend ( ( event ) => {
166187 delete event . release ;
You can’t perform that action at this time.
0 commit comments