Skip to content

Commit 274ab3c

Browse files
authored
Merge pull request #51 from Flechaa/fix-null-crash
fix: null message crash and drop array messages
2 parents c57e6e4 + 2cbe9cd commit 274ab3c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/connections/src/lib/deviceControlConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class DeviceControlConnection extends EventEmitter {
8888
// Do nothing
8989
}
9090

91-
if (typeof msg !== 'object') {
91+
if (typeof msg !== 'object' || Array.isArray(msg) || msg == null) {
9292
this.log.error(`Device /control - error decoding message, disconnecting`);
9393
this.ws.close();
9494
return;
@@ -164,7 +164,7 @@ export class DeviceControlConnection extends EventEmitter {
164164
//< {"id":7,"status":200,"body":{"memFree":123, ...}}
165165

166166
const memory = await this.executeCommand<MemoryStatus>('getMemoryUsage', null, 5000);
167-
if (typeof memory === 'object') {
167+
if (typeof memory === 'object' && !Array.isArray(msg) && msg != null) {
168168
this.lastMemory = memory; // spy on result
169169
}
170170
return memory;

0 commit comments

Comments
 (0)