@hotmeshio/hotmesh 0.22.5 → 0.22.7
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/build/package.json +1 -1
- package/build/services/durable/client.js +4 -1
- package/build/services/durable/schemas/factory.d.ts +1 -1
- package/build/services/durable/schemas/factory.js +7 -1
- package/build/services/durable/worker.js +10 -1
- package/build/services/engine/version.js +15 -4
- package/package.json +1 -1
package/build/package.json
CHANGED
|
@@ -365,7 +365,10 @@ class ClientService {
|
|
|
365
365
|
throw error;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
else if (isNaN(Number(appVersion)) ||
|
|
368
|
+
else if (isNaN(Number(appVersion)) ||
|
|
369
|
+
Number(appVersion) < Number(version)) {
|
|
370
|
+
// Numeric compare: string `<` mis-orders at digit boundaries (e.g. '9' < '16'
|
|
371
|
+
// is false as strings). Redeploy + hot-swap when an older schema is deployed.
|
|
369
372
|
try {
|
|
370
373
|
await hotMesh.deploy((0, factory_1.getWorkflowYAML)(appId, version));
|
|
371
374
|
await hotMesh.activate(version);
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.APP_ID = exports.APP_VERSION = exports.getWorkflowYAML = void 0;
|
|
4
|
-
|
|
4
|
+
// Schema content version for the generated durable app YAML below. BUMP THIS
|
|
5
|
+
// whenever `getWorkflowYAML` changes — it is how existing deployments detect a
|
|
6
|
+
// schema upgrade and hot-swap to it (see WorkerService.activateWorkflow and
|
|
7
|
+
// ClientService.deployAndActivate). Changing the YAML without a bump leaves
|
|
8
|
+
// every already-deployed database on the old schema forever. Numeric string —
|
|
9
|
+
// compared with `Number()` for ordering. (v16: condition() escalation hook.)
|
|
10
|
+
const APP_VERSION = '16';
|
|
5
11
|
exports.APP_VERSION = APP_VERSION;
|
|
6
12
|
const APP_ID = 'durable';
|
|
7
13
|
exports.APP_ID = APP_ID;
|
|
@@ -128,7 +128,16 @@ class WorkerService {
|
|
|
128
128
|
static async activateWorkflow(hotMesh) {
|
|
129
129
|
const app = await hotMesh.engine.store.getApp(hotMesh.engine.appId);
|
|
130
130
|
const appVersion = app?.version;
|
|
131
|
-
if (!appVersion
|
|
131
|
+
if (!appVersion ||
|
|
132
|
+
isNaN(Number(appVersion)) ||
|
|
133
|
+
Number(appVersion) < Number(factory_1.APP_VERSION)) {
|
|
134
|
+
// Not deployed, or an OLDER schema version is deployed (the SDK was
|
|
135
|
+
// upgraded). Deploy this SDK's schema and hot-swap to it. HotMesh keeps
|
|
136
|
+
// the prior version deployed, so in-flight jobs drain on the old schema
|
|
137
|
+
// while new jobs use APP_VERSION. Without this branch an existing, active
|
|
138
|
+
// app would never pick up a new schema — atomic-escalation hooks and any
|
|
139
|
+
// other schema-encoded feature would silently never activate after an
|
|
140
|
+
// upgrade. Mirrors ClientService.deployAndActivate.
|
|
132
141
|
try {
|
|
133
142
|
await hotMesh.deploy((0, factory_1.getWorkflowYAML)(hotMesh.engine.appId, factory_1.APP_VERSION));
|
|
134
143
|
await hotMesh.activate(factory_1.APP_VERSION);
|
|
@@ -49,10 +49,21 @@ async function getVID(instance, vid) {
|
|
|
49
49
|
}
|
|
50
50
|
return { id: instance.appId, version: app.version };
|
|
51
51
|
}
|
|
52
|
-
else if (!instance.apps
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
else if (!instance.apps) {
|
|
53
|
+
// First call — always DB-refresh to avoid locking in a stale version.
|
|
54
|
+
// The `vid` parameter originates from store.getApp() (which may be
|
|
55
|
+
// cached from before the last activation). If a worker missed the
|
|
56
|
+
// nocache NOTIFY (startup race: LISTEN not yet established when the
|
|
57
|
+
// NOTIFY fired), it would lock in the pre-activation version for its
|
|
58
|
+
// entire lifetime, silently loading the old schema on every request.
|
|
59
|
+
// One extra DB query here, once per engine lifetime, eliminates the
|
|
60
|
+
// race regardless of NOTIFY delivery.
|
|
61
|
+
const id = vid?.id ?? instance.appId;
|
|
62
|
+
const freshApp = await instance.store.getApp(id, true);
|
|
63
|
+
if (!instance.apps)
|
|
64
|
+
instance.apps = {};
|
|
65
|
+
instance.apps[instance.appId] = freshApp;
|
|
66
|
+
return { id: freshApp.id, version: freshApp.version };
|
|
56
67
|
}
|
|
57
68
|
else {
|
|
58
69
|
return await fetchAndVerifyVID(instance, {
|