lightflow-engine 0.2.8 → 0.2.9
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.js +12 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,7 +39,16 @@ export function registerWorkflow(id, fn) {
|
|
|
39
39
|
export function registerStep(id, fn) {
|
|
40
40
|
steps.set(id, fn);
|
|
41
41
|
}
|
|
42
|
-
export let current = null;
|
|
42
|
+
export let current = globalThis.__lightflowCurrent ?? null;
|
|
43
|
+
if (!globalThis.__lightflowCurrent) {
|
|
44
|
+
globalThis.__lightflowCurrent = null;
|
|
45
|
+
}
|
|
46
|
+
// Keep the live binding in sync: `current` assignments below must write both.
|
|
47
|
+
function setCurrent(v) {
|
|
48
|
+
current = v;
|
|
49
|
+
globalThis.__lightflowCurrent = v;
|
|
50
|
+
}
|
|
51
|
+
// Rewrite plain assignments on `current` below to setCurrent(...)
|
|
43
52
|
export function getWorkflowMetadata() {
|
|
44
53
|
if (!current)
|
|
45
54
|
throw new Error("getWorkflowMetadata() outside a workflow");
|
|
@@ -369,7 +378,7 @@ export class Engine {
|
|
|
369
378
|
},
|
|
370
379
|
};
|
|
371
380
|
const prev = current;
|
|
372
|
-
|
|
381
|
+
setCurrent(ctx);
|
|
373
382
|
try {
|
|
374
383
|
const output = await fn(...args);
|
|
375
384
|
await Promise.all(ctx.inflight);
|
|
@@ -397,7 +406,7 @@ export class Engine {
|
|
|
397
406
|
return fail(err instanceof Error ? err.message : String(err));
|
|
398
407
|
}
|
|
399
408
|
finally {
|
|
400
|
-
|
|
409
|
+
setCurrent(prev);
|
|
401
410
|
await claimer.releaseRun?.(runId);
|
|
402
411
|
}
|
|
403
412
|
}
|