Skip to content

Commit 2032818

Browse files
authored
watch method crash on unexpected objects
The watch method should not crash if the k8s's reply object contains no `type` or `object`. Instead we check if the reply is an actual object and callback even if the `type` is `undefined` Should fix (at least partially) #146
1 parent 9ef9571 commit 2032818

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)