From 3c5f897b267e7d770259f05ac101cc5dec679d3d Mon Sep 17 00:00:00 2001 From: Max Richter Date: Thu, 7 May 2026 21:12:10 +0200 Subject: [PATCH] feat: bunch of small fixes --- .../lib/graph-interface/helpers/nodeHelpers.ts | 2 +- .../lib/node-registry/node-registry-client.ts | 1 + .../project-manager/project-manager.svelte.ts | 2 +- app/src/lib/runtime/remote-runtime-executor.ts | 18 ------------------ app/src/lib/runtime/runtime-executor.ts | 7 +++---- .../runtime/worker-runtime-executor-backend.ts | 4 ++++ 6 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 app/src/lib/runtime/remote-runtime-executor.ts diff --git a/app/src/lib/graph-interface/helpers/nodeHelpers.ts b/app/src/lib/graph-interface/helpers/nodeHelpers.ts index 177e1ac..32ef6e6 100644 --- a/app/src/lib/graph-interface/helpers/nodeHelpers.ts +++ b/app/src/lib/graph-interface/helpers/nodeHelpers.ts @@ -38,7 +38,7 @@ export function serializeNode(node: SerializedNode | NodeInstance): SerializedNo id: node.id, position: [...node.position], type: node.type, - props: node.props + props: node.props ? JSON.parse(JSON.stringify(node.props)) : undefined }; } diff --git a/app/src/lib/node-registry/node-registry-client.ts b/app/src/lib/node-registry/node-registry-client.ts index 37feabe..386aa4b 100644 --- a/app/src/lib/node-registry/node-registry-client.ts +++ b/app/src/lib/node-registry/node-registry-client.ts @@ -141,6 +141,7 @@ export class RemoteNodeRegistry implements NodeRegistry { wrapper = createWasmWrapper(wasmBuffer); } catch (error) { console.error(`Failed to create node wrapper for node: ${id}`, error); + throw error; } const rawDefinition = wrapper.get_definition(); diff --git a/app/src/lib/project-manager/project-manager.svelte.ts b/app/src/lib/project-manager/project-manager.svelte.ts index f6f53dd..b6b43d7 100644 --- a/app/src/lib/project-manager/project-manager.svelte.ts +++ b/app/src/lib/project-manager/project-manager.svelte.ts @@ -19,7 +19,7 @@ export class ProjectManager { } async saveGraph(g: Graph) { - db.saveGraph(g); + await db.saveGraph(g); } private async init() { diff --git a/app/src/lib/runtime/remote-runtime-executor.ts b/app/src/lib/runtime/remote-runtime-executor.ts deleted file mode 100644 index 915b3bd..0000000 --- a/app/src/lib/runtime/remote-runtime-executor.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Graph, RuntimeExecutor } from '@nodarium/types'; - -export class RemoteRuntimeExecutor implements RuntimeExecutor { - constructor(private url: string) {} - - async execute(graph: Graph, settings: Record): Promise { - const res = await fetch(this.url, { - method: 'POST', - body: JSON.stringify({ graph, settings }) - }); - - if (!res.ok) { - throw new Error(`Failed to execute graph`); - } - - return new Int32Array(await res.arrayBuffer()); - } -} diff --git a/app/src/lib/runtime/runtime-executor.ts b/app/src/lib/runtime/runtime-executor.ts index d552dda..785990e 100644 --- a/app/src/lib/runtime/runtime-executor.ts +++ b/app/src/lib/runtime/runtime-executor.ts @@ -173,9 +173,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { constructor( private registry: NodeRegistry, public cache?: SyncCache - ) { - this.cache = undefined; - } + ) {} private async getNodeDefinitions(graph: Graph) { if (this.registry.status !== 'ready') { @@ -314,6 +312,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { continue; } + a = performance.now(); // Collect the inputs for the node @@ -399,7 +398,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { log.groupEnd(); } catch (e) { log.groupEnd(); - log.error(`Error executing node ${node_type.id || node.id}`, e); + throw e; } } diff --git a/app/src/lib/runtime/worker-runtime-executor-backend.ts b/app/src/lib/runtime/worker-runtime-executor-backend.ts index 2def545..0905680 100644 --- a/app/src/lib/runtime/worker-runtime-executor-backend.ts +++ b/app/src/lib/runtime/worker-runtime-executor-backend.ts @@ -2,6 +2,7 @@ import { debugNode } from '$lib/node-registry/debugNode'; import { IndexDBCache, RemoteNodeRegistry } from '$lib/node-registry/index'; import type { Graph } from '@nodarium/types'; import { createPerformanceStore } from '@nodarium/utils'; +import * as Comlink from 'comlink'; import { MemoryRuntimeExecutor } from './runtime-executor'; import { MemoryRuntimeCache } from './runtime-executor-cache'; @@ -38,6 +39,9 @@ export async function executeGraph( performanceStore.startRun(); const res = await executor.execute(graph, settings); performanceStore.stopRun(); + if (res?.buffer) { + return Comlink.transfer(res, [res.buffer]); + } return res; }