Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: Cancel jobs

Andras Bacsaifebef372b892
diff --git a/src/routes/applications/[id]/cancel.json.ts b/src/routes/applications/[id]/cancel.json.ts
index 11c83ae9cc..b819098870 100644
--- a/src/routes/applications/[id]/cancel.json.ts
+++ b/src/routes/applications/[id]/cancel.json.ts
@@ -22,16 +22,17 @@ export const post: RequestHandler = async (event) => {
} = job.data;
const host = getEngine(engine);
let interval = setInterval(async () => {
- const { status } = await db.prisma.build.findUnique({ where: { id: buildId } });
- if (status === 'failed') {
- clearInterval(interval);
- return resolve();
- }
- if (count > 1200) {
- clearInterval(interval);
- reject(new Error('Could not cancel build.'));
- }
try {
+ const data = await db.prisma.build.findUnique({ where: { id: buildId } });
+ if (data?.status === 'failed') {
+ clearInterval(interval);
+ return resolve();
+ }
+ if (count > 60) {
+ clearInterval(interval);
+ reject(new Error('Could not cancel build.'));
+ }
+
const { stdout: buildContainers } = await asyncExecShell(
`DOCKER_HOST=${host} docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'`
);
@@ -53,7 +54,7 @@ export const post: RequestHandler = async (event) => {
}
count++;
} catch (error) {}
- }, 100);
+ }, 1000);
resolve();
});