mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00
fix: destroy后仍有push流
This commit is contained in:
@@ -121,7 +121,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
if (!content) return;
|
if (!content) return;
|
||||||
responseContent += content;
|
responseContent += content;
|
||||||
// console.log('content:', content)
|
// console.log('content:', content)
|
||||||
stream.push(content.replace(/\n/g, '<br/>'));
|
!stream.destroyed && stream.push(content.replace(/\n/g, '<br/>'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error;
|
error;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('pipe error', error);
|
console.log('pipe error', error);
|
||||||
}
|
}
|
||||||
stream.push(null);
|
// close stream
|
||||||
|
stream.destroy();
|
||||||
|
|
||||||
const promptsLen = formatPrompts.reduce((sum, item) => sum + item.content.length, 0);
|
const promptsLen = formatPrompts.reduce((sum, item) => sum + item.content.length, 0);
|
||||||
console.log(`responseLen: ${responseContent.length}`, `promptLen: ${promptsLen}`);
|
console.log(`responseLen: ${responseContent.length}`, `promptLen: ${promptsLen}`);
|
||||||
@@ -154,8 +155,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (step === 1) {
|
if (step === 1) {
|
||||||
console.log('error,结束');
|
|
||||||
// 直接结束流
|
// 直接结束流
|
||||||
|
console.log('error,结束');
|
||||||
stream.destroy();
|
stream.destroy();
|
||||||
} else {
|
} else {
|
||||||
res.status(500);
|
res.status(500);
|
||||||
|
@@ -14,15 +14,9 @@ export const pushBill = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
await connectToDatabase();
|
await connectToDatabase();
|
||||||
|
|
||||||
const modelItem = modelList.find((item) => item.model === modelName);
|
|
||||||
|
|
||||||
if (!modelItem) return;
|
|
||||||
|
|
||||||
let billId;
|
let billId;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await connectToDatabase();
|
|
||||||
|
|
||||||
const modelItem = modelList.find((item) => item.model === modelName);
|
const modelItem = modelList.find((item) => item.model === modelName);
|
||||||
|
|
||||||
if (!modelItem) return;
|
if (!modelItem) return;
|
||||||
|
Reference in New Issue
Block a user