Check if abort is a function

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen committed 2021-11-23 13:35:01 +02:00
1 parent 068a92365e
commit 37eef77d4b
1 file changed
+4 -4
+4 -4
View File
@@ -549,10 +549,10 @@ export class KubeApi<T extends KubeObject> {
logger.info(`[KUBE-API] system suspended, abort watching of ${watchUrl}...`);
try {
if (opts.abortController) {
opts.abortController.abort?.();
} else {
abort?.();
if (typeof opts.abortController?.abort === "function") {
opts.abortController.abort();
} else if (typeof abort === "function") {
abort();
}
} catch (error) {
logger.error(`[KUBE-API] error aborting watch (${watchId})`, error);