Ironclad / rivet

The open-source visual AI programming environment and TypeScript library
https://rivet.ironcladapp.com
MIT License
2.55k stars 226 forks source link

[Bug]: Outputting an array via code node produces a render error for the node (and I'm pretty sure tanks the performance) #379

Closed andris1 closed 3 months ago

andris1 commented 3 months ago

What happened?

I have this code node that takes arr1 like ['a', 'b'] and arr2 like [['1', '2', '3', '4', '5'], ['7','8','9','10','11']] and produces arr3 like [[a,1][a,2][a,3][a,4][a,5],[b,7],[b,8],[b,9],[b,10],[b,11]].

The code node works, but it doesn't render the output (shows a rendering error).

And I'm pretty sure is the cause of a rendering-related performance drop for that graph (can barely click & drag the graph).

The code for the code node:

for(let i = 0; i < inputs.arr1.value.length; i++) {
    for(let j = 0; j < inputs.arr2.value[i].length; j++) {
        arr3.push([inputs.arr1.value[i], inputs.arr2.value[i][j]])
    }
}
return {
    arr3: {
        type: 'string[]',
        value: arr3
    }
};

What was the expected functionality?

Expected no rendering error or performance impact.

Describe your environment

Win11. Browser mode.

Relevant log output

No response

Relevant screenshots

No response

Code of Conduct

abrenneke commented 3 months ago

It's expecting you to output a string[], so it's trying to render a list of strings, but it's actually a string[][] so that's why the rendering error is happening

andris1 commented 3 months ago

omg :/ 🤦 ; that is true