mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-25 21:01:54 +08:00
🚑️ Fix maximum callstack size issue from setVariableHistory
This commit is contained in:
parent
08ad39558a
commit
21767d2eee
@ -83,11 +83,12 @@ export const walkFlowForward = async (
|
||||
isOffDefaultPath: nextEdge?.isOffDefaultPath ?? false,
|
||||
});
|
||||
newSessionState = nextGroupResponse.newSessionState;
|
||||
if (nextGroupResponse.visitedEdge)
|
||||
visitedEdges.push(nextGroupResponse.visitedEdge);
|
||||
if (!nextGroupResponse?.group) break;
|
||||
const executionResponse = await executeGroup(nextGroupResponse.group, {
|
||||
version,
|
||||
state: newSessionState,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
skipFirstMessageBubble,
|
||||
timeoutStartTime,
|
||||
@ -96,10 +97,8 @@ export const walkFlowForward = async (
|
||||
});
|
||||
if (executionResponse.logs) logs.push(...executionResponse.logs);
|
||||
newSessionState = executionResponse.newSessionState;
|
||||
if (executionResponse.visitedEdges)
|
||||
visitedEdges.push(...executionResponse.visitedEdges);
|
||||
if (executionResponse.setVariableHistory)
|
||||
setVariableHistory.push(...executionResponse.setVariableHistory);
|
||||
if (executionResponse.newSetVariableHistoryItems)
|
||||
setVariableHistory.push(...executionResponse.newSetVariableHistoryItems);
|
||||
if (executionResponse.messages)
|
||||
messages.push(...executionResponse.messages);
|
||||
if (executionResponse.input) input = executionResponse.input;
|
||||
@ -133,7 +132,6 @@ type ContextProps = {
|
||||
sessionStore: SessionStore;
|
||||
currentLastBubbleId?: string;
|
||||
skipFirstMessageBubble?: boolean;
|
||||
visitedEdges: Prisma.VisitedEdge[];
|
||||
setVariableHistory: SetVariableHistoryItem[];
|
||||
timeoutStartTime?: number;
|
||||
textBubbleContentFormat: "richText" | "markdown";
|
||||
@ -141,8 +139,7 @@ type ContextProps = {
|
||||
|
||||
export type ExecuteGroupResponse = ContinueChatResponse & {
|
||||
newSessionState: SessionState;
|
||||
setVariableHistory: SetVariableHistoryItem[];
|
||||
visitedEdges: Prisma.VisitedEdge[];
|
||||
newSetVariableHistoryItems: SetVariableHistoryItem[];
|
||||
updatedTimeoutStartTime?: number;
|
||||
nextEdge?: {
|
||||
id: string;
|
||||
@ -156,7 +153,6 @@ const executeGroup = async (
|
||||
version,
|
||||
state,
|
||||
sessionStore,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
currentLastBubbleId,
|
||||
skipFirstMessageBubble,
|
||||
@ -170,7 +166,7 @@ const executeGroup = async (
|
||||
let nextEdge;
|
||||
let lastBubbleBlockId: string | undefined = currentLastBubbleId;
|
||||
let updatedTimeoutStartTime = timeoutStartTime;
|
||||
|
||||
const newSetVariableHistoryItems: SetVariableHistoryItem[] = [];
|
||||
let newSessionState = state;
|
||||
|
||||
let index = -1;
|
||||
@ -216,8 +212,7 @@ const executeGroup = async (
|
||||
},
|
||||
clientSideActions,
|
||||
logs,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
newSetVariableHistoryItems,
|
||||
};
|
||||
}
|
||||
|
||||
@ -238,8 +233,7 @@ const executeGroup = async (
|
||||
},
|
||||
clientSideActions,
|
||||
logs,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
newSetVariableHistoryItems,
|
||||
};
|
||||
const logicOrIntegrationExecutionResponse = (
|
||||
isLogicBlock(block)
|
||||
@ -282,7 +276,7 @@ const executeGroup = async (
|
||||
},
|
||||
};
|
||||
else
|
||||
setVariableHistory.push(
|
||||
newSetVariableHistoryItems.push(
|
||||
...logicOrIntegrationExecutionResponse.newSetVariableHistory,
|
||||
);
|
||||
}
|
||||
@ -333,8 +327,7 @@ const executeGroup = async (
|
||||
},
|
||||
clientSideActions,
|
||||
logs,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
newSetVariableHistoryItems,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -357,8 +350,7 @@ const executeGroup = async (
|
||||
clientSideActions,
|
||||
updatedTimeoutStartTime,
|
||||
logs,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
newSetVariableHistoryItems,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user