@bian-womp/spark-workbench 0.3.52 → 0.3.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.cjs CHANGED
@@ -1206,6 +1206,14 @@ class LocalGraphRunner extends AbstractGraphRunner {
1206
1206
  this.emit("transport", { runnerId: this.runnerId, state: "local" });
1207
1207
  }
1208
1208
  build(def, opts) {
1209
+ // Rebuilding should not leave the previous runtime alive.
1210
+ // In practice, launch() calls build() and can be triggered multiple times for the same UI "flow".
1211
+ // Disposing here avoids multiple GraphRuntime instances accumulating and emitting events.
1212
+ if (this.runtime) {
1213
+ console.info(`[LocalGraphRunner] Disposing previous runtime before building new one`);
1214
+ this.runtime.dispose();
1215
+ this.runtime = undefined;
1216
+ }
1209
1217
  const builder = new sparkGraph.GraphBuilder(this.registry);
1210
1218
  this.runtime = builder.build(def, opts);
1211
1219
  // Signal UI that freshly built graph should be considered invalidated