diff --git a/README.md b/README.md index b53efcf..4e73b69 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ Any use of the source code and related documents of this repository in applicati * 2024-03-19: 1.9.5 - fix: update dependencies in package-lock * 2024-05-24: 1.9.6 - fix: catch exception when server sends invalid/incomplete json in subscription (Bug849302). - fix: add more tests to handle node address with invalid symbols +* 2024-12-06: 1.9.7 - fix: update dependencies in package-lock + - fix: further improve resilience on invalid data from server ``` ## About diff --git a/lib/CtrlxDatalayerSubscription.js b/lib/CtrlxDatalayerSubscription.js index f24c12b..5aa50af 100644 --- a/lib/CtrlxDatalayerSubscription.js +++ b/lib/CtrlxDatalayerSubscription.js @@ -435,7 +435,9 @@ class CtrlxDatalayerSubscription extends EventEmitter { setTimeout(()=>this.emit('update', payload, e.lastEventId), 0); } } catch (err) { - this.emit('error', new Error(`Error parsing update event: ${err.message}`)); + if (this.listeners('error').length > 0) { + this.emit('error', new Error(`Error parsing update event: ${err.message}`)); + } } }); @@ -452,7 +454,9 @@ class CtrlxDatalayerSubscription extends EventEmitter { setTimeout(()=>this.emit('keepalive', payload, e.lastEventId), 0); } } catch (err) { - this.emit('error', new Error(`Error parsing keepalive event: ${err.message}`)); + if (this.listeners('error').length > 0) { + this.emit('error', new Error(`Error parsing keepalive event: ${err.message}`)); + } } });