Skip to content

Commit 45e0987

Browse files
authored
Merge pull request #148 from scaccogatto/patch-1
watch method crash on unexpected objects
2 parents 9ef9571 + 2032818 commit 45e0987

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/watch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export class Watch {
6060
} else {
6161
obj = JSON.parse(data) as WatchUpdate;
6262
}
63-
if (obj.type && obj.object) {
63+
if (typeof obj === 'object' && obj.object) {
6464
callback(obj.type, obj.object);
6565
} else {
66-
throw new Error(`unexpected object: ${JSON.stringify(obj)}`);
66+
throw new Error(`unexpected ${typeof obj}: ${JSON.stringify(obj)}`);
6767
}
6868
});
6969

0 commit comments

Comments
 (0)