@rebasepro/server-core 0.0.1-canary.ca2cb6e → 0.0.1-canary.dbf160a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +8 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +8 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -8
- package/src/cron/cron-scheduler.ts +10 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/server-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.1-canary.
|
|
4
|
+
"version": "0.0.1-canary.dbf160a",
|
|
5
5
|
"description": "Database-Agnostic Backend Core for Rebase",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -46,16 +46,17 @@
|
|
|
46
46
|
"@hono/node-server": "1.19.12",
|
|
47
47
|
"google-auth-library": "^9.0.0",
|
|
48
48
|
"graphql": "^16.8.1",
|
|
49
|
-
"hono": "4.12.10",
|
|
49
|
+
"hono": "^4.12.10",
|
|
50
50
|
"jose": "^6.1.3",
|
|
51
51
|
"jsonwebtoken": "^9.0.0",
|
|
52
52
|
"nodemailer": "^6.9.0",
|
|
53
|
+
"ts-morph": "27.0.2",
|
|
53
54
|
"ws": "^8.16.0",
|
|
54
55
|
"zod": "^3.22.4",
|
|
55
|
-
"@rebasepro/
|
|
56
|
-
"@rebasepro/
|
|
57
|
-
"@rebasepro/utils": "0.0.1-canary.
|
|
58
|
-
"@rebasepro/
|
|
56
|
+
"@rebasepro/types": "0.0.1-canary.dbf160a",
|
|
57
|
+
"@rebasepro/client": "0.0.1-canary.dbf160a",
|
|
58
|
+
"@rebasepro/utils": "0.0.1-canary.dbf160a",
|
|
59
|
+
"@rebasepro/common": "0.0.1-canary.dbf160a"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@types/jest": "^29.5.14",
|
|
@@ -69,8 +70,8 @@
|
|
|
69
70
|
"ts-jest": "29.4.1",
|
|
70
71
|
"typescript": "^5.0.0",
|
|
71
72
|
"vite": "^5.0.0",
|
|
72
|
-
"@rebasepro/types": "0.0.1-canary.
|
|
73
|
-
"@rebasepro/common": "0.0.1-canary.
|
|
73
|
+
"@rebasepro/types": "0.0.1-canary.dbf160a",
|
|
74
|
+
"@rebasepro/common": "0.0.1-canary.dbf160a"
|
|
74
75
|
},
|
|
75
76
|
"gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
|
|
76
77
|
"publishConfig": {
|
|
@@ -282,6 +282,9 @@ export class CronScheduler {
|
|
|
282
282
|
const job = this.jobs.get(id);
|
|
283
283
|
if (!job || !job.enabled || !this.started) return;
|
|
284
284
|
|
|
285
|
+
// Clear any previously scheduled timer to prevent double-firing
|
|
286
|
+
this.stopJob(id);
|
|
287
|
+
|
|
285
288
|
try {
|
|
286
289
|
const now = new Date();
|
|
287
290
|
const nextRun = parseCronExpression(job.definition.schedule, now);
|
|
@@ -342,11 +345,16 @@ export class CronScheduler {
|
|
|
342
345
|
// Race with timeout
|
|
343
346
|
const timeout = (job.definition.timeoutSeconds ?? 300) * 1000;
|
|
344
347
|
const handlerPromise = Promise.resolve(job.definition.handler(ctx));
|
|
348
|
+
let timeoutHandle: ReturnType<typeof setTimeout>;
|
|
345
349
|
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
346
|
-
setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
|
|
350
|
+
timeoutHandle = setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
|
|
347
351
|
});
|
|
348
352
|
|
|
349
|
-
|
|
353
|
+
try {
|
|
354
|
+
result = await Promise.race([handlerPromise, timeoutPromise]);
|
|
355
|
+
} finally {
|
|
356
|
+
clearTimeout(timeoutHandle!);
|
|
357
|
+
}
|
|
350
358
|
} catch (err: unknown) {
|
|
351
359
|
success = false;
|
|
352
360
|
error = err instanceof Error ? err.message : String(err);
|