Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:template frontend leaves zombie git processes #4799

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions frontend/providers/template/src/pages/api/updateRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

await Promise.race([gitOperationPromise, timeoutPromise]);
const gitConfigResult = await execAsync(
'git config --global --add safe.directory /app/providers/template/templates',
{ timeout: 10000 }
);

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ const Form = ({
className="template-dynamic-label"
color={'#333'}
userSelect={'none'}
whiteSpace={'pre-wrap'}
wordBreak={'break-word'}
>
{item?.label}
{item?.required && (
Expand Down
Loading