@bian-womp/spark-remote 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
|
@@ -446,6 +446,24 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
|
|
|
446
446
|
});
|
|
447
447
|
},
|
|
448
448
|
build: async (def, opts) => {
|
|
449
|
+
// If we rebuild the graph, we must not keep the previous runtime/engine alive.
|
|
450
|
+
// This can happen for a single "flow" when:
|
|
451
|
+
// - server bootstraps an empty graph (no snapshot) then client sends Build with real def
|
|
452
|
+
// - snapshot load / applySnapshotFull triggers a build
|
|
453
|
+
// - client intentionally rebuilds the graph
|
|
454
|
+
//
|
|
455
|
+
// Without disposing, we can end up with multiple GraphRuntime instances in memory
|
|
456
|
+
// for the same flow/connection, each holding listeners/resources.
|
|
457
|
+
if (engine) {
|
|
458
|
+
console.info(`[ServerRuntimeAdapter:${id}] Disposing previous engine before building new one`);
|
|
459
|
+
engine.dispose();
|
|
460
|
+
engine = undefined;
|
|
461
|
+
}
|
|
462
|
+
if (graphRuntime) {
|
|
463
|
+
console.info(`[ServerRuntimeAdapter:${id}] Disposing previous graph runtime before building new one`);
|
|
464
|
+
graphRuntime.dispose();
|
|
465
|
+
graphRuntime = undefined;
|
|
466
|
+
}
|
|
449
467
|
const environment = opts?.environment || {};
|
|
450
468
|
graphRuntime = builder.build(def, {
|
|
451
469
|
environment,
|