@hatchet-dev/typescript-sdk 1.19.1 → 1.19.2-alpha.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.
- package/package.json +4 -4
- package/v1/client/worker/worker-internal.js +2 -2
- package/v1/declaration.js +8 -6
- package/v1/parent-run-context-vars.js +4 -6
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.2-alpha.0",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@bufbuild/protobuf": "^2.11.0",
|
|
50
50
|
"@types/qs": "^6.15.0",
|
|
51
|
-
"abort-controller-x": "^0.
|
|
51
|
+
"abort-controller-x": "^0.5.0",
|
|
52
52
|
"axios": "^1.13.5",
|
|
53
53
|
"long": "^5.3.1",
|
|
54
54
|
"nice-grpc": "^2.1.14",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@grpc/grpc-js": "^1.14.3",
|
|
65
65
|
"@opentelemetry/api": "^1.9.0",
|
|
66
66
|
"@opentelemetry/core": "^2.0.0",
|
|
67
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "^0.
|
|
68
|
-
"@opentelemetry/instrumentation": "^0.
|
|
67
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.214.0",
|
|
68
|
+
"@opentelemetry/instrumentation": "^0.214.0",
|
|
69
69
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
70
70
|
"prom-client": "^15.1.3"
|
|
71
71
|
},
|
|
@@ -95,10 +95,10 @@ class InternalWorker {
|
|
|
95
95
|
this.labels = options.labels || {};
|
|
96
96
|
this.enableHealthServer = (_b = (_a = client.config.healthcheck) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false;
|
|
97
97
|
this.healthPort = (_d = (_c = client.config.healthcheck) === null || _c === void 0 ? void 0 : _c.port) !== null && _d !== void 0 ? _d : 8001;
|
|
98
|
-
process.on('SIGTERM', () => this.exitGracefully(true));
|
|
99
|
-
process.on('SIGINT', () => this.exitGracefully(true));
|
|
100
98
|
this.killing = false;
|
|
101
99
|
this.handle_kill = options.handleKill === undefined ? true : options.handleKill;
|
|
100
|
+
process.on('SIGTERM', () => this.exitGracefully(this.handle_kill));
|
|
101
|
+
process.on('SIGINT', () => this.exitGracefully(this.handle_kill));
|
|
102
102
|
this.logger = client.config.logger(`Worker/${this.name}`, this.client.config.log_level);
|
|
103
103
|
if (this.enableHealthServer && this.healthPort) {
|
|
104
104
|
this.initializeHealthServer();
|
package/v1/declaration.js
CHANGED
|
@@ -63,9 +63,12 @@ class BaseWorkflowDeclaration {
|
|
|
63
63
|
if (!this.client) {
|
|
64
64
|
throw UNBOUND_ERR;
|
|
65
65
|
}
|
|
66
|
-
// set the parent run context
|
|
67
66
|
const parentRunContext = parent_run_context_vars_1.parentRunContextManager.getContext();
|
|
68
|
-
|
|
67
|
+
// Snapshot the child index BEFORE incrementing — getContext() returns a mutable
|
|
68
|
+
// reference, so any later increment would corrupt this value.
|
|
69
|
+
const childIndex = parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.childIndex;
|
|
70
|
+
const inputCount = Array.isArray(input) ? input.length : 1;
|
|
71
|
+
parent_run_context_vars_1.parentRunContextManager.incrementChildIndex(inputCount);
|
|
69
72
|
if (!parentRunContext && ((options === null || options === void 0 ? void 0 : options.childKey) || (options === null || options === void 0 ? void 0 : options.sticky))) {
|
|
70
73
|
this.client.admin.logger.warn('ignoring childKey or sticky because run is not being spawned from a parent task');
|
|
71
74
|
}
|
|
@@ -79,18 +82,17 @@ class BaseWorkflowDeclaration {
|
|
|
79
82
|
: undefined,
|
|
80
83
|
warn: (message) => this.client.admin.logger.warn(message),
|
|
81
84
|
});
|
|
82
|
-
|
|
83
|
-
const runOpts = Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { parentId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentId, parentTaskRunExternalId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentTaskRunExternalId, childIndex: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.childIndex, sticky: (options === null || options === void 0 ? void 0 : options.sticky) ? parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.desiredWorkerId : undefined, childKey: options === null || options === void 0 ? void 0 : options.childKey });
|
|
85
|
+
const runOpts = Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { parentId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentId, parentTaskRunExternalId: parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.parentTaskRunExternalId, childIndex, sticky: (options === null || options === void 0 ? void 0 : options.sticky) ? parentRunContext === null || parentRunContext === void 0 ? void 0 : parentRunContext.desiredWorkerId : undefined, childKey: options === null || options === void 0 ? void 0 : options.childKey });
|
|
84
86
|
if (Array.isArray(input)) {
|
|
85
87
|
let resp = [];
|
|
86
88
|
for (let i = 0; i < input.length; i += 500) {
|
|
87
89
|
const batch = input.slice(i, i + 500);
|
|
88
|
-
const batchResp = yield this.client.admin.runWorkflows(batch.map((inp) => {
|
|
90
|
+
const batchResp = yield this.client.admin.runWorkflows(batch.map((inp, batchIdx) => {
|
|
89
91
|
var _a;
|
|
90
92
|
return ({
|
|
91
93
|
workflowName: this.definition.name,
|
|
92
94
|
input: inp,
|
|
93
|
-
options: Object.assign(Object.assign({}, runOpts), { childIndex: ((_a = runOpts.childIndex) !== null && _a !== void 0 ? _a : 0) + i }),
|
|
95
|
+
options: Object.assign(Object.assign({}, runOpts), { childIndex: ((_a = runOpts.childIndex) !== null && _a !== void 0 ? _a : 0) + i + batchIdx }),
|
|
94
96
|
});
|
|
95
97
|
}));
|
|
96
98
|
resp = resp.concat(batchResp);
|
|
@@ -16,18 +16,16 @@ class ParentRunContextManager {
|
|
|
16
16
|
var _a;
|
|
17
17
|
const parentRunContext = this.getContext();
|
|
18
18
|
if (parentRunContext) {
|
|
19
|
-
parentRunContext.parentId
|
|
20
|
-
parentRunContext.parentTaskRunExternalId = opts.parentTaskRunExternalId;
|
|
21
|
-
parentRunContext.childIndex = ((_a = parentRunContext.childIndex) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
22
|
-
this.setContext(parentRunContext);
|
|
19
|
+
this.setContext(Object.assign(Object.assign({}, parentRunContext), { parentId: opts.parentId, parentTaskRunExternalId: opts.parentTaskRunExternalId, childIndex: ((_a = parentRunContext.childIndex) !== null && _a !== void 0 ? _a : 0) + 1 }));
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
incrementChildIndex(n) {
|
|
26
23
|
var _a;
|
|
27
24
|
const parentRunContext = this.getContext();
|
|
28
25
|
if (parentRunContext) {
|
|
29
|
-
|
|
30
|
-
this.
|
|
26
|
+
// Build a fresh object to avoid mutating the live store reference, which
|
|
27
|
+
// would corrupt any values snapshotted before this call.
|
|
28
|
+
this.setContext(Object.assign(Object.assign({}, parentRunContext), { childIndex: ((_a = parentRunContext.childIndex) !== null && _a !== void 0 ? _a : 0) + n }));
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
getContext() {
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.19.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.19.2-alpha.0";
|
package/version.js
CHANGED