From 97a1ccb773ef306b82163563f8231b5e33e86aea Mon Sep 17 00:00:00 2001 From: juaning Date: Tue, 30 Nov 2021 13:39:52 -0300 Subject: [PATCH] Fix issues where access to properties were failing --- src/utils/image-utils.ts | 4 +++- src/utils/mqtt.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/image-utils.ts b/src/utils/image-utils.ts index c26c744..973c901 100644 --- a/src/utils/image-utils.ts +++ b/src/utils/image-utils.ts @@ -25,7 +25,9 @@ export class ImageUtils { public static resizeCanvas(inputCanvas: Canvas, targetWidth: number, targetHeight: number): Canvas { const canvas: Canvas = createCanvas(targetWidth, targetHeight); const ctx = canvas.getContext('2d'); - ctx.drawImage(inputCanvas, 0, 0, inputCanvas.width, inputCanvas.height, 0, 0, targetWidth, targetHeight); + if (inputCanvas) { + ctx.drawImage(inputCanvas, 0, 0, inputCanvas.width, inputCanvas.height, 0, 0, targetWidth, targetHeight); + } return canvas; } diff --git a/src/utils/mqtt.ts b/src/utils/mqtt.ts index f021ead..b897eab 100644 --- a/src/utils/mqtt.ts +++ b/src/utils/mqtt.ts @@ -44,7 +44,7 @@ export class Mqtt { private onConnection(): Promise { return new Promise((resolve, reject) => { let interval = setInterval(() => { - if (this.client.connected) { + if (this.client && this.client.connected) { clearInterval(interval); resolve(); }