File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export class ExternalWorkerClient {
5252 }
5353 } catch ( e ) {
5454 console . error ( 'Failed to execute job with exception' , e ) ;
55- await this . _restClient . failJob ( { jobId, errorMessage : typeof e === 'string' ? e : JSON . stringify ( e ) } ) ;
55+ await this . _restClient . failJob ( { jobId, errorMessage : typeof e === 'string' ? e : this . stringify ( e ) } ) ;
5656 }
5757 }
5858 if ( timeoutInformation . unsubscribed ) {
@@ -61,6 +61,23 @@ export class ExternalWorkerClient {
6161 } while ( jobs . length > 0 ) ;
6262 timeoutInformation . timeout = setTimeout ( ( ) => this . consume ( params , timeoutInformation ) , timeoutInformation . waitMs ) ;
6363 }
64+
65+ private stringify ( obj ) {
66+ let cache = [ ] ;
67+ let str = JSON . stringify ( obj , function ( key , value ) {
68+ if ( typeof value === "object" && value !== null ) {
69+ if ( cache . indexOf ( value ) !== - 1 ) {
70+ // Circular reference found, discard key
71+ return ;
72+ }
73+ // Store value in our collection
74+ cache . push ( value ) ;
75+ }
76+ return value ;
77+ } ) ;
78+ cache = null ; // reset the cache
79+ return str ;
80+ }
6481}
6582
6683class TimeoutInformation {
You can’t perform that action at this time.
0 commit comments