fix(core): Resolve host data paths once per expression evaluation

Merged
LO
2d ago
+612-160

Summary

Reading an array from an expression parameter could repeat the same calculation for every element and cause QuickJS to time out. This PR reuses resolved host values within each evaluation.

The fix applies to both QuickJS and isolated-vm.

Why

Consider an ids parameter that contains:

{{ $input.all().map(item => item.json.id) }}

Reading {{ $parameter.ids }} looks simple. But the runtime reads array elements on demand. Each read used to resolve the path from the root, which could run the entire map() again.

The array is now resolved once and reused while its elements are read.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/CET-540

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)