diff --git a/openvidu-node-client/src/Session.ts b/openvidu-node-client/src/Session.ts index 7c22655a..cad8028c 100644 --- a/openvidu-node-client/src/Session.ts +++ b/openvidu-node-client/src/Session.ts @@ -200,7 +200,7 @@ export class Session { */ public fetch(): Promise { return new Promise((resolve, reject) => { - const beforeJSON: string = JSON.stringify(this); + const beforeJSON: string = JSON.stringify(this, this.removeCircularOpenViduReference); axios.get( 'https://' + this.ov.hostname + ':' + this.ov.port + OpenVidu.API_SESSIONS + '/' + this.sessionId, { @@ -214,7 +214,7 @@ export class Session { if (res.status === 200) { // SUCCESS response from openvidu-server this.resetSessionWithJson(res.data); - const afterJSON: string = JSON.stringify(this); + const afterJSON: string = JSON.stringify(this, this.removeCircularOpenViduReference); const hasChanged: boolean = !(beforeJSON === afterJSON); console.log("Session info fetched for session '" + this.sessionId + "'. Any change: " + hasChanged); resolve(hasChanged); @@ -528,4 +528,15 @@ export class Session { } } + /** + * @hidden + */ + private removeCircularOpenViduReference(key: string, value: any) { + if (key === 'ov' && value instanceof OpenVidu) { + return; + } else { + return value; + } + } + } \ No newline at end of file