Commit 10e443f
committed
fix: make Frame.lookup() iterative to prevent StackOverflowError
Java does not optimize tail calls. On JVMs with smaller default thread
stack sizes (e.g. Windows workers, containers with -Xss256k), deeply
nested JSONata expressions cause Jsonata$Frame.lookup() to overflow the
stack via tail recursion. StackOverflowError is a JVM Error — it cannot
be safely caught and the entire worker thread crashes.
Replace the recursive parent.lookup(name) call with an iterative loop
over the scope chain. Semantics are identical; traversal order is
unchanged. Eliminates all stack risk from scope chain lookup regardless
of nesting depth.
Fixes worker crashes reported in kestra-io/plugin-transform#79.1 parent 0b40af3 commit 10e443f
1 file changed
Lines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
98 | 97 | | |
99 | 98 | | |
100 | 99 | | |
| |||
0 commit comments