@btravstack/temporal-worker 0.30.0 → 0.31.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.
Files changed (2) hide show
  1. package/dist/index.mjs +9 -3
  2. package/package.json +10 -10
package/dist/index.mjs CHANGED
@@ -174,6 +174,7 @@ const DEFAULT_FORCE_MS = 15e3;
174
174
  * have to reach the worker as the same number.
175
175
  */
176
176
  const durationMs = (duration) => duration === void 0 ? void 0 : msToNumber(duration);
177
+ const workerRuns = /* @__PURE__ */ new WeakMap();
177
178
  /**
178
179
  * The Temporal starter: a module providing the runtime, its configuration
179
180
  * (bound from the `TEMPORAL_*` variables unless pinned) and the connection (a
@@ -210,7 +211,11 @@ const temporal = (options) => {
210
211
  address: bound.address,
211
212
  cause
212
213
  })),
213
- release: (connection) => connection.close().catch((cause) => heldByWorker(cause) ? void 0 : Promise.reject(cause))
214
+ release: (connection) => connection.close().catch((cause) => {
215
+ const running = workerRuns.get(connection);
216
+ if (!heldByWorker(cause) || running === void 0) return Promise.reject(cause);
217
+ return Promise.resolve(running).then(() => connection.close());
218
+ })
214
219
  }),
215
220
  noObserverMember,
216
221
  Provider(TemporalRuntime)({
@@ -255,7 +260,7 @@ const createWorker = (host, connection, config, activities, options, observers)
255
260
  activities: handler,
256
261
  shutdownGraceTime: config.gracePeriodMs,
257
262
  shutdownForceTime: config.forceAfterMs
258
- }), startFailed)).map((worker) => poll(worker, taskQueue, namespace));
263
+ }), startFailed)).map((worker) => poll(worker, taskQueue, namespace, connection));
259
264
  };
260
265
  /**
261
266
  * The `Serving` over a started worker.
@@ -265,8 +270,9 @@ const createWorker = (host, connection, config, activities, options, observers)
265
270
  * to make a real one do that without taking the shared Temporal server down for
266
271
  * every other spec. A stub worker is what reaches that arm.
267
272
  */
268
- const poll = (worker, taskQueue, namespace) => {
273
+ const poll = (worker, taskQueue, namespace, connection) => {
269
274
  const running = fromSafePromise(worker.run());
275
+ if (connection !== void 0) workerRuns.set(connection, running);
270
276
  const stopPolling = () => {
271
277
  if (worker.getState() === "RUNNING") worker.shutdown();
272
278
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btravstack/temporal-worker",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "The Temporal worker runtime for @btravstack/core: one unit per activity attempt, and a drain that honours the kernel's deadline",
5
5
  "keywords": [
6
6
  "graceful-shutdown",
@@ -46,11 +46,11 @@
46
46
  }
47
47
  },
48
48
  "devDependencies": {
49
- "@btravstack/config": "0.30.0",
50
- "@btravstack/core": "0.30.0",
51
- "@btravstack/di": "0.30.0",
49
+ "@btravstack/config": "0.31.0",
50
+ "@btravstack/core": "0.31.0",
51
+ "@btravstack/di": "0.31.0",
52
52
  "@btravstack/internal-test-infra": "0.0.0",
53
- "@btravstack/testing": "0.30.0",
53
+ "@btravstack/testing": "0.31.0",
54
54
  "@btravstack/tsconfig": "0.4.0",
55
55
  "@temporal-contract/client": "8.0.0-beta.11",
56
56
  "@temporal-contract/contract": "8.0.0-beta.11",
@@ -61,19 +61,19 @@
61
61
  "@temporalio/worker": "1.24.0",
62
62
  "@temporalio/workflow": "1.24.0",
63
63
  "@types/node": "26.6.4",
64
- "@unthrown/vitest": "5.12.0",
64
+ "@unthrown/vitest": "5.12.1",
65
65
  "@vitest/coverage-v8": "5.0.3",
66
66
  "tsdown": "0.23.0",
67
67
  "typescript": "7.0.2",
68
68
  "typescript-consumer": "npm:typescript@5.9.3",
69
- "unthrown": "5.12.0",
69
+ "unthrown": "5.12.1",
70
70
  "vitest": "5.0.3",
71
71
  "zod": "4.6.5"
72
72
  },
73
73
  "peerDependencies": {
74
- "@btravstack/config": "^0.30.0",
75
- "@btravstack/core": "^0.30.0",
76
- "@btravstack/di": "^0.30.0",
74
+ "@btravstack/config": "^0.31.0",
75
+ "@btravstack/core": "^0.31.0",
76
+ "@btravstack/di": "^0.31.0",
77
77
  "@temporal-contract/client": "^8.0.0-beta.9",
78
78
  "@temporal-contract/contract": "^8.0.0-beta.9",
79
79
  "@temporal-contract/worker": "^8.0.0-beta.9",