mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
Perf: vector queue and app ui (#1750)
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
import { addLog } from '../system/log';
|
||||
import { connectionMongo, ClientSession } from './index';
|
||||
|
||||
export const mongoSessionRun = async <T = unknown>(fn: (session: ClientSession) => Promise<T>) => {
|
||||
const session = await connectionMongo.startSession();
|
||||
let committed = false;
|
||||
|
||||
try {
|
||||
session.startTransaction();
|
||||
const result = await fn(session);
|
||||
|
||||
await session.commitTransaction();
|
||||
committed = true;
|
||||
|
||||
return result as T;
|
||||
} catch (error) {
|
||||
await session.abortTransaction();
|
||||
if (!committed) {
|
||||
await session.abortTransaction();
|
||||
} else {
|
||||
addLog.warn('Un catch mongo session error', { error });
|
||||
}
|
||||
return Promise.reject(error);
|
||||
} finally {
|
||||
await session.endSession();
|
||||
|
@@ -217,16 +217,16 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
||||
|
||||
if (res?.closed || props.maxRunTimes <= 0) return;
|
||||
props.maxRunTimes--;
|
||||
console.log(props.maxRunTimes, user._id);
|
||||
addLog.debug(`Run node`, { maxRunTimes: props.maxRunTimes, uid: user._id });
|
||||
|
||||
await surrenderProcess();
|
||||
|
||||
if (status === 'run') {
|
||||
addLog.info(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
|
||||
addLog.debug(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
|
||||
return nodeRunWithActive(node);
|
||||
}
|
||||
if (status === 'skip') {
|
||||
addLog.info(`[dispatchWorkFlow] nodeRunWithSkip: ${node.name}`);
|
||||
addLog.debug(`[dispatchWorkFlow] nodeRunWithSkip: ${node.name}`);
|
||||
return nodeRunWithSkip(node);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user