From 50c4c87e625ce4f306163591b544d8bfb732f0c7 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 5 Aug 2024 15:41:12 -0400 Subject: [PATCH] Add error boundary on node.DrawBackground (#311) --- src/scripts/app.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 4c953b998b..7e7bbb57f4 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -657,7 +657,7 @@ export class ComfyApp { } } - node.prototype.onDrawBackground = function (ctx) { + function unsafeDrawBackground(ctx) { if (!this.flags.collapsed) { let imgURLs = [] let imagesChanged = false @@ -992,6 +992,14 @@ export class ComfyApp { } } } + + node.prototype.onDrawBackground = function (ctx) { + try { + unsafeDrawBackground.call(this, ctx) + } catch (error) { + console.error('Error drawing node background', error) + } + } } /**