@velajs/vela 1.2.0 → 1.4.0

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.
@@ -7,18 +7,26 @@ function _ts_decorate(decorators, target, key, desc) {
7
7
  function _ts_metadata(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  }
10
- import { Injectable } from "../container/index.js";
10
+ function _ts_param(paramIndex, decorator) {
11
+ return function(target, key) {
12
+ decorator(target, key, paramIndex);
13
+ };
14
+ }
15
+ import { Inject, Injectable } from "../container/index.js";
16
+ import { Container } from "../container/container.js";
11
17
  import { parseCron } from "../schedule/cron-matcher.js";
12
18
  import { ScheduleRegistry } from "../schedule/schedule.registry.js";
13
19
  export class ScheduleExecutor {
14
20
  registry;
21
+ container;
15
22
  intervalTimers = [];
16
23
  cronTimers = [];
17
24
  cronMatcherCache = new Map();
18
25
  lastCronMinute = new Map();
19
26
  running = true;
20
- constructor(registry){
27
+ constructor(registry, container){
21
28
  this.registry = registry;
29
+ this.container = container;
22
30
  }
23
31
  onApplicationBootstrap() {
24
32
  if (typeof setInterval !== 'function') {
@@ -61,8 +69,14 @@ export class ScheduleExecutor {
61
69
  if (typeof method === 'function') {
62
70
  await method.call(instance);
63
71
  }
64
- } catch {
65
- // Swallow errors so the scheduler keeps running
72
+ } catch (err) {
73
+ // Runtime job error — keep the scheduler running by default. Users
74
+ // can opt into rethrowing by setting diagnostics: 'throw'.
75
+ const mode = this.container.getDiagnostics();
76
+ if (mode === 'throw') throw err;
77
+ if (mode === 'log') {
78
+ console.warn(`[vela] scheduled job ${methodName} failed:`, err);
79
+ }
66
80
  }
67
81
  }
68
82
  getMatcher(expression) {
@@ -84,8 +98,10 @@ export class ScheduleExecutor {
84
98
  }
85
99
  ScheduleExecutor = _ts_decorate([
86
100
  Injectable(),
101
+ _ts_param(1, Inject(Container)),
87
102
  _ts_metadata("design:type", Function),
88
103
  _ts_metadata("design:paramtypes", [
89
- typeof ScheduleRegistry === "undefined" ? Object : ScheduleRegistry
104
+ typeof ScheduleRegistry === "undefined" ? Object : ScheduleRegistry,
105
+ typeof Container === "undefined" ? Object : Container
90
106
  ])
91
107
  ], ScheduleExecutor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velajs/vela",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "NestJS-compatible framework for edge runtimes, powered by Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -61,17 +61,21 @@
61
61
  "hono": "^4"
62
62
  },
63
63
  "devDependencies": {
64
+ "@cloudflare/vitest-pool-workers": "^0.15.2",
64
65
  "@swc/cli": "^0.8.0",
65
66
  "@swc/core": "^1.15.11",
66
67
  "@types/bun": "latest",
68
+ "@vitest/runner": "^4.1.5",
69
+ "@vitest/snapshot": "^4.1.5",
67
70
  "typescript": "^5",
68
71
  "unplugin-swc": "^1.5.9",
69
- "vitest": "^4.0.18",
72
+ "vitest": "^4.1.5",
70
73
  "zod": "^4.3.6"
71
74
  },
72
75
  "scripts": {
73
76
  "build": "rm -rf dist && swc src -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
74
77
  "test": "vitest run",
78
+ "test:workers": "vitest run --config vitest.config.workers.ts",
75
79
  "typecheck": "tsc --noEmit"
76
80
  }
77
81
  }