From 0707cb5074ca096db4ce2954dd8a521e4524f8d1 Mon Sep 17 00:00:00 2001 From: jingyang <72259332+zjy365@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:17:44 +0800 Subject: [PATCH] fix:template frontend leaves zombie git processes (#4799) * fix:template process issue * update label width --- .../template/src/pages/api/updateRepo.ts | 23 +++++++++++-------- .../src/pages/deploy/components/Form.tsx | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend/providers/template/src/pages/api/updateRepo.ts b/frontend/providers/template/src/pages/api/updateRepo.ts index 1b0834720..ea8eb7939 100644 --- a/frontend/providers/template/src/pages/api/updateRepo.ts +++ b/frontend/providers/template/src/pages/api/updateRepo.ts @@ -74,17 +74,20 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< const branch = process.env.TEMPLATE_REPO_BRANCH || 'main'; try { - execAsync('git config --global --add safe.directory /app/providers/template/templates'); - const timeoutPromise = new Promise((resolve, reject) => { - setTimeout(() => { - reject(new Error('operation timed out')); - }, 60 * 1000); - }); - const gitOperationPromise = !fs.existsSync(targetPath) - ? execAsync(`git clone -b ${branch} ${repoHttpUrl} ${targetPath} --depth=1`) - : execAsync(`cd ${targetPath} && git pull --depth=1 --rebase`); + const gitConfigResult = await execAsync( + 'git config --global --add safe.directory /app/providers/template/templates', + { timeout: 10000 } + ); - await Promise.race([gitOperationPromise, timeoutPromise]); + console.log('git config:', gitConfigResult); + + const gitCommand = !fs.existsSync(targetPath) + ? `git clone -b ${branch} ${repoHttpUrl} ${targetPath} --depth=1` + : `cd ${targetPath} && git pull --depth=1 --rebase`; + + const result = await execAsync(gitCommand, { timeout: 60000 }); + + console.log('git operation:', result); } catch (error) { console.log('git operation timed out: \n', error); } diff --git a/frontend/providers/template/src/pages/deploy/components/Form.tsx b/frontend/providers/template/src/pages/deploy/components/Form.tsx index 70b236897..aa9cdd11b 100644 --- a/frontend/providers/template/src/pages/deploy/components/Form.tsx +++ b/frontend/providers/template/src/pages/deploy/components/Form.tsx @@ -103,6 +103,8 @@ const Form = ({ className="template-dynamic-label" color={'#333'} userSelect={'none'} + whiteSpace={'pre-wrap'} + wordBreak={'break-word'} > {item?.label} {item?.required && (