From 5c6a0f98b255418927f28d0f12cf18521d1f0f46 Mon Sep 17 00:00:00 2001 From: Terry Jia Date: Sun, 23 Nov 2025 21:53:11 -0500 Subject: [PATCH] code improve --- src/services/eagerExecutionService.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/services/eagerExecutionService.ts b/src/services/eagerExecutionService.ts index fb8637d9c6..37bcb495d6 100644 --- a/src/services/eagerExecutionService.ts +++ b/src/services/eagerExecutionService.ts @@ -41,6 +41,9 @@ class EagerExecutionService { return } this.enabled = false + this.changedNodes.clear() + this.lastChangeTimestamp.clear() + this.executionPending = false } private setupEventListeners() { @@ -151,6 +154,16 @@ class EagerExecutionService { this.lastChangeTimestamp.set(nodeId, now) + // Clean up old entries periodically to prevent memory leak + if (this.lastChangeTimestamp.size > 1000) { + const cutoff = now - 60000 // Remove entries older than 1 minute + for (const [id, timestamp] of this.lastChangeTimestamp.entries()) { + if (timestamp < cutoff) { + this.lastChangeTimestamp.delete(id) + } + } + } + if (this.isExecuting) { return }