From 7c5a2ae8e0fb81e758fe261a602332d9447bcc5d Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Tue, 5 Jun 2018 15:17:28 -0400 Subject: [PATCH] Add check that block associated with comment actually exists. --- src/engine/target.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/target.js b/src/engine/target.js index 3faab5d4c..2e3b67789 100644 --- a/src/engine/target.js +++ b/src/engine/target.js @@ -209,7 +209,13 @@ class Target extends EventEmitter { width, height, minimized); if (blockId) { newComment.blockId = blockId; - this.blocks.getBlock(blockId).comment = id; + const blockWithComment = this.blocks.getBlock(blockId); + if (blockWithComment) { + blockWithComment.comment = id; + } else { + log.warn(`Could not find block with id ${blockId + } associated with commentId: ${id}`); + } } this.comments[id] = newComment; }