@codemation/core 0.13.0 → 0.13.1

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/testing.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  const require_di = require('./di-C-2ep8NZ.cjs');
2
2
  require('./contracts-CK0x6w_G.cjs');
3
- const require_runtime = require('./runtime-DjYXgOo0.cjs');
3
+ const require_runtime = require('./runtime-rrH8-Ouq.cjs');
4
4
  const require_InMemoryRunEventBusRegistry = require('./InMemoryRunEventBusRegistry-Sa86VxuV.cjs');
5
- const require_bootstrap = require('./bootstrap-BEu1fJBM.cjs');
5
+ const require_bootstrap = require('./bootstrap-UDyH8OfK.cjs');
6
6
  let tsyringe = require("tsyringe");
7
7
  tsyringe = require_di.__toESM(tsyringe);
8
8
 
package/dist/testing.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { d as CoreTokens } from "./di-D9Mv3kF3.js";
2
2
  import "./contracts-DXdfTdpW.js";
3
- import { A as PersistedWorkflowTokenRegistry, C as DefaultDrivingScheduler, G as AllWorkflowsActiveWorkflowActivationPolicy, N as NodeExecutor, O as NodeInstanceFactory, S as HintOnlyOffloadPolicy, V as DefaultExecutionContextFactory, a as InMemoryLiveWorkflowRepository, i as RunIntentService, it as emitPorts, k as WorkflowSnapshotCodec, l as Engine, p as InMemoryRunDataFactory, st as DefaultAsyncSleeper, x as InlineDrivingScheduler, yt as WorkflowBuilder, z as InProcessRetryRunner } from "./runtime-6-U2Cou5.js";
3
+ import { A as PersistedWorkflowTokenRegistry, C as DefaultDrivingScheduler, G as AllWorkflowsActiveWorkflowActivationPolicy, N as NodeExecutor, O as NodeInstanceFactory, S as HintOnlyOffloadPolicy, V as DefaultExecutionContextFactory, a as InMemoryLiveWorkflowRepository, i as RunIntentService, it as emitPorts, k as WorkflowSnapshotCodec, l as Engine, p as InMemoryRunDataFactory, st as DefaultAsyncSleeper, x as InlineDrivingScheduler, yt as WorkflowBuilder, z as InProcessRetryRunner } from "./runtime-iHBN1jyD.js";
4
4
  import { t as InMemoryRunEventBus } from "./InMemoryRunEventBusRegistry-Bwunvt1T.js";
5
- import { a as InMemoryWorkflowExecutionRepository, t as EngineRuntimeRegistrar } from "./bootstrap-CSeInbj1.js";
5
+ import { a as InMemoryWorkflowExecutionRepository, t as EngineRuntimeRegistrar } from "./bootstrap-DB3jpo8F.js";
6
6
  import { container } from "tsyringe";
7
7
 
8
8
  //#region src/testing/RejectingCredentialSessionService.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemation/core",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,6 +15,8 @@ export class InlineDrivingScheduler implements NodeActivationScheduler {
15
15
  Array<Readonly<{ request: NodeActivationRequest; receipt: NodeActivationReceipt }>>
16
16
  >();
17
17
  private readonly scheduledRuns = new Set<string>();
18
+ private stopped = false;
19
+ private readonly activeDrainPromises = new Set<Promise<void>>();
18
20
 
19
21
  constructor(private readonly nodeExecutor: NodeExecutor) {}
20
22
 
@@ -22,6 +24,21 @@ export class InlineDrivingScheduler implements NodeActivationScheduler {
22
24
  this.continuation = continuation;
23
25
  }
24
26
 
27
+ /**
28
+ * Prevents new drain cycles from being scheduled and waits for all currently-running
29
+ * drains to complete. Call before closing the DB connection or rolling back test transactions
30
+ * to ensure no in-flight writes hit a closed/rolled-back connection.
31
+ *
32
+ * Bounded: only the drains already in-flight at call time are awaited. Runs that keep
33
+ * re-scheduling will not schedule new work once stopped is set.
34
+ */
35
+ async stop(): Promise<void> {
36
+ this.stopped = true;
37
+ if (this.activeDrainPromises.size > 0) {
38
+ await Promise.allSettled(this.activeDrainPromises);
39
+ }
40
+ }
41
+
25
42
  async prepareDispatch(request: NodeActivationRequest): Promise<PreparedNodeActivationDispatch> {
26
43
  const receipt: NodeActivationReceipt = { receiptId: request.activationId, mode: "local" };
27
44
  return {
@@ -77,7 +94,7 @@ export class InlineDrivingScheduler implements NodeActivationScheduler {
77
94
  }
78
95
 
79
96
  private scheduleDrain(runId: string): void {
80
- if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) {
97
+ if (this.stopped || this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) {
81
98
  return;
82
99
  }
83
100
  this.scheduledRuns.add(runId);
@@ -85,7 +102,11 @@ export class InlineDrivingScheduler implements NodeActivationScheduler {
85
102
  // giving queued HTTP writes and WS frames a chance to flush between activations.
86
103
  setImmediate(() => {
87
104
  this.scheduledRuns.delete(runId);
88
- void this.drainRun(runId);
105
+ if (this.stopped) return;
106
+ const p = this.drainRun(runId).finally(() => {
107
+ this.activeDrainPromises.delete(p);
108
+ });
109
+ this.activeDrainPromises.add(p);
89
110
  });
90
111
  }
91
112