From ccb832d095de7d7b65ee07743ba8cf8025b86948 Mon Sep 17 00:00:00 2001 From: vicke4 Date: Wed, 27 Aug 2025 12:21:25 +0530 Subject: [PATCH 1/2] fix: server crash in self-hosted instances --- packages/api/src/app/cron.ts | 14 ++++++-------- packages/api/src/controllers/Identities.ts | 11 +++++++---- packages/api/src/controllers/Tasks.ts | 9 ++++++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/api/src/app/cron.ts b/packages/api/src/app/cron.ts index 8b4c9f9..679176b 100644 --- a/packages/api/src/app/cron.ts +++ b/packages/api/src/app/cron.ts @@ -1,13 +1,13 @@ import cron from "node-cron"; import signale from "signale"; -import { API_URI } from "./constants"; -export const task = cron.schedule("* * * * *", () => { +import { Identities } from "../controllers/Identities"; +import { Tasks } from "../controllers/Tasks"; + +export const task = cron.schedule("* * * * *", async () => { signale.info("Running scheduled tasks"); try { - void fetch(`${API_URI}/tasks`, { - method: "POST", - }); + await (new Tasks().handleTasks()); } catch (e) { signale.error("Failed to run scheduled tasks. Please check the error below"); console.error(e); @@ -15,9 +15,7 @@ export const task = cron.schedule("* * * * *", () => { signale.info("Updating verified identities"); try { - void fetch(`${API_URI}/identities/update`, { - method: "POST", - }); + await (new Identities().updateIdentities()); } catch (e) { signale.error("Failed to update verified identities. Please check the error below"); console.error(e); diff --git a/packages/api/src/controllers/Identities.ts b/packages/api/src/controllers/Identities.ts index eb1f08e..730918a 100644 --- a/packages/api/src/controllers/Identities.ts +++ b/packages/api/src/controllers/Identities.ts @@ -99,7 +99,12 @@ export class Identities { } @Post("update") - public async updateIdentities(req: Request, res: Response) { + public async updateIdentitiesApi(req: Request, res: Response) { + await (new Identities().updateIdentities()); + return res.status(200).json({ success: true }); + } + + public async updateIdentities() { const count = await prisma.project.count({ where: { email: { not: null } }, }); @@ -155,8 +160,6 @@ export class Identities { await redis.del(Keys.Project.public(project.public)); } } - } - - return res.status(200).json({ success: true }); + } } } diff --git a/packages/api/src/controllers/Tasks.ts b/packages/api/src/controllers/Tasks.ts index 4e00342..4633a55 100644 --- a/packages/api/src/controllers/Tasks.ts +++ b/packages/api/src/controllers/Tasks.ts @@ -9,7 +9,12 @@ import { ProjectService } from "../services/ProjectService"; @Controller("tasks") export class Tasks { @Post() - public async handleTasks(req: Request, res: Response) { + public async handleTasksApi(req: Request, res: Response) { + await (new Tasks().handleTasks()); + return res.status(200).json({ success: true }); + } + + public async handleTasks() { // Get all tasks with a runBy data in the past const tasks = await prisma.task.findMany({ where: { runBy: { lte: new Date() } }, @@ -128,7 +133,5 @@ export class Tasks { signale.success(`Task completed for ${contact.email} from ${project.name}`); } - - return res.status(200).json({ success: true }); } } From 560a8f27d4bae5072c30453e462f6688912c982f Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Fri, 5 Sep 2025 13:30:35 +0200 Subject: [PATCH 2/2] Bump version from 1.3.0 to 1.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e4dbf6..383fb6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plunk", - "version": "1.3.0", + "version": "1.3.1", "private": true, "license": "agpl-3.0", "workspaces": {