From bb2ad03193238af6a4d6a0007f3d7e67b5cad096 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Tue, 23 Mar 2021 22:10:52 +0100 Subject: [PATCH] Unref scope, result, input vars when creating stacktrace frame --- pkg/wfexec/state.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/wfexec/state.go b/pkg/wfexec/state.go index deeaa2857..b24de6602 100644 --- a/pkg/wfexec/state.go +++ b/pkg/wfexec/state.go @@ -1,6 +1,7 @@ package wfexec import ( + "encoding/json" "github.com/cortezaproject/corteza-server/pkg/auth" "github.com/cortezaproject/corteza-server/pkg/expr" "time" @@ -126,13 +127,24 @@ func (s State) loopCurr() Iterator { } func (s State) MakeFrame() *Frame { + var ( + // might not be the most optimal way but we need to + // un-reference scope, input, result variables + unref = func(vars *expr.Vars) *expr.Vars { + out := &expr.Vars{} + tmp, _ := json.Marshal(vars) + _ = json.Unmarshal(tmp, out) + return out + } + ) + f := &Frame{ CreatedAt: s.created, SessionID: s.sessionId, StateID: s.stateId, - Input: s.input, - Scope: s.scope, - Results: s.results, + Input: unref(s.input), + Scope: unref(s.scope), + Results: unref(s.results), NextSteps: s.next.IDs(), Action: s.action, }