@nwire/forge 0.12.0 → 0.12.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.
@@ -77,8 +77,22 @@ export function createForgePlugin(options = {}) {
77
77
  // Pin the dispatch chain handler step at priority -Infinity so any
78
78
  // user `runtime.use()` middleware stays strictly outside the
79
79
  // handler invocation.
80
+ //
81
+ // The runtime installs its OWN core step (`__nwire_runtime_core__`,
82
+ // also -Infinity) the first time a `runtime.use()` middleware routes
83
+ // a dispatch through the chain. Both steps would otherwise call
84
+ // `coreFn()`, so a forge action running while any user middleware is
85
+ // present would execute its handler twice. Guard the call with a
86
+ // per-dispatch sentinel: whichever -Infinity step runs first invokes
87
+ // the handler; the rest fall through. Forge keeps its own step
88
+ // because it dispatches straight through `dispatchHook$.run`, where
89
+ // the runtime's lazily-pinned step may not exist yet.
80
90
  runtime.dispatchHook$.use(async (hctx, next) => {
81
- hctx.result = await hctx.coreFn();
91
+ const h = hctx;
92
+ if (!h.__nwireCoreInvoked) {
93
+ h.__nwireCoreInvoked = true;
94
+ hctx.result = await hctx.coreFn();
95
+ }
82
96
  await next();
83
97
  }, { name: "handler", priority: -Infinity });
84
98
  // Domain registration runs at AppBooting — after every plugin's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/forge",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Nwire — the framework's core primitives. defineAction, defineEvent, defineHandler, defineActor, defineProjection, defineQuery, defineWorkflow, defineModule, defineApp, definePlugin, createApp. MessageEnvelope with correlation/causation. The runtime is the bus.",
5
5
  "keywords": [
6
6
  "actions",
@@ -34,16 +34,16 @@
34
34
  "emittery": "1.0.1",
35
35
  "koa": "^2.16.4",
36
36
  "zod": "^4.0.0",
37
- "@nwire/app": "0.12.0",
38
- "@nwire/bus": "0.12.0",
39
- "@nwire/container": "0.12.0",
40
- "@nwire/dead-letter": "0.12.0",
41
- "@nwire/envelope": "0.12.0",
42
- "@nwire/hooks": "0.12.0",
43
- "@nwire/messages": "0.12.0",
44
- "@nwire/handler": "0.12.0",
45
- "@nwire/wires": "0.12.0",
46
- "@nwire/logger": "0.12.0"
37
+ "@nwire/bus": "0.12.1",
38
+ "@nwire/container": "0.12.1",
39
+ "@nwire/dead-letter": "0.12.1",
40
+ "@nwire/app": "0.12.1",
41
+ "@nwire/handler": "0.12.1",
42
+ "@nwire/envelope": "0.12.1",
43
+ "@nwire/hooks": "0.12.1",
44
+ "@nwire/logger": "0.12.1",
45
+ "@nwire/messages": "0.12.1",
46
+ "@nwire/wires": "0.12.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/koa": "^2.15.0",