@@ -354,7 +354,13 @@ export function addSpanEventWithIncomingRequestData(options: AddSpanEventWithInc
354
354
355
355
if ( query ) {
356
356
if ( typeof query === 'object' && Object . keys ( query ) . length ) {
357
- const value = truncateString ( JSON . stringify ( query , null , 2 ) )
357
+ let value = 'object could not be stringified to JSON'
358
+ try {
359
+ value = truncateString ( JSON . stringify ( query , null , 2 ) )
360
+ }
361
+ catch ( err ) {
362
+ void err
363
+ }
358
364
Object . defineProperty ( attrs , AttrNames . Http_Request_Query , {
359
365
...defaultProperty ,
360
366
value,
@@ -363,7 +369,13 @@ export function addSpanEventWithIncomingRequestData(options: AddSpanEventWithInc
363
369
}
364
370
365
371
if ( data && Object . keys ( data ) . length ) {
366
- const value = truncateString ( JSON . stringify ( data , null , 2 ) )
372
+ let value = 'object could not be stringified to JSON'
373
+ try {
374
+ value = truncateString ( JSON . stringify ( data , null , 2 ) )
375
+ }
376
+ catch ( err ) {
377
+ void err
378
+ }
367
379
Object . defineProperty ( attrs , AttrNames . Http_Request_Body , {
368
380
...defaultProperty ,
369
381
value,
@@ -404,7 +416,12 @@ export function addSpanEventWithOutgoingResponseData(options: AddSpanEventWithOu
404
416
405
417
let value = ''
406
418
if ( typeof body === 'object' ) {
407
- value = truncateString ( JSON . stringify ( body , null , 2 ) )
419
+ try {
420
+ value = truncateString ( JSON . stringify ( body , null , 2 ) )
421
+ }
422
+ catch {
423
+ value = 'object could not be stringified to JSON'
424
+ }
408
425
}
409
426
else if ( typeof body === 'string' ) {
410
427
value = body ? truncateString ( body ) : ''
0 commit comments