@blokjs/runner 0.6.20 → 0.7.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/dist/Blok.d.ts +2 -0
- package/dist/Blok.js +42 -110
- package/dist/Blok.js.map +1 -1
- package/dist/DefaultLogger.d.ts +13 -0
- package/dist/DefaultLogger.js +25 -0
- package/dist/DefaultLogger.js.map +1 -1
- package/dist/RunnerSteps.d.ts +23 -0
- package/dist/RunnerSteps.js +128 -87
- package/dist/RunnerSteps.js.map +1 -1
- package/dist/SubworkflowNode.js +19 -0
- package/dist/SubworkflowNode.js.map +1 -1
- package/dist/TriggerBase.d.ts +12 -0
- package/dist/TriggerBase.js +216 -181
- package/dist/TriggerBase.js.map +1 -1
- package/dist/adapters/grpc/GrpcRuntimeAdapter.d.ts +9 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js +76 -6
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js.map +1 -1
- package/dist/index.d.ts +4 -39
- package/dist/index.js +7 -32
- package/dist/index.js.map +1 -1
- package/dist/monitoring/JanitorMetrics.d.ts +3 -0
- package/dist/monitoring/JanitorMetrics.js +11 -0
- package/dist/monitoring/JanitorMetrics.js.map +1 -1
- package/dist/monitoring/ProcessErrorMetrics.d.ts +32 -0
- package/dist/monitoring/ProcessErrorMetrics.js +43 -0
- package/dist/monitoring/ProcessErrorMetrics.js.map +1 -0
- package/dist/monitoring/PrometheusMetricsBridge.d.ts +7 -0
- package/dist/monitoring/PrometheusMetricsBridge.js +8 -2
- package/dist/monitoring/PrometheusMetricsBridge.js.map +1 -1
- package/dist/monitoring/SubworkflowMetrics.d.ts +25 -0
- package/dist/monitoring/SubworkflowMetrics.js +38 -0
- package/dist/monitoring/SubworkflowMetrics.js.map +1 -0
- package/dist/observability/ErrorSink.d.ts +23 -0
- package/dist/observability/ErrorSink.js +32 -0
- package/dist/observability/ErrorSink.js.map +1 -0
- package/dist/observability/SentryIntegration.d.ts +9 -0
- package/dist/observability/SentryIntegration.js +31 -0
- package/dist/observability/SentryIntegration.js.map +1 -0
- package/dist/scheduling/DebounceCoordinator.d.ts +7 -53
- package/dist/scheduling/DebounceCoordinator.js +8 -207
- package/dist/scheduling/DebounceCoordinator.js.map +1 -1
- package/dist/tracing/InMemoryRunStore.d.ts +5 -1
- package/dist/tracing/InMemoryRunStore.js +14 -0
- package/dist/tracing/InMemoryRunStore.js.map +1 -1
- package/dist/tracing/Janitor.js +3 -0
- package/dist/tracing/Janitor.js.map +1 -1
- package/dist/tracing/PostgresRunStore.d.ts +4 -1
- package/dist/tracing/PostgresRunStore.js +73 -3
- package/dist/tracing/PostgresRunStore.js.map +1 -1
- package/dist/tracing/RunStore.d.ts +17 -1
- package/dist/tracing/RunTracker.d.ts +13 -34
- package/dist/tracing/RunTracker.js +62 -32
- package/dist/tracing/RunTracker.js.map +1 -1
- package/dist/tracing/SqliteRunStore.d.ts +4 -1
- package/dist/tracing/SqliteRunStore.js +60 -0
- package/dist/tracing/SqliteRunStore.js.map +1 -1
- package/dist/tracing/TraceRouter.d.ts +13 -0
- package/dist/tracing/TraceRouter.js +43 -11
- package/dist/tracing/TraceRouter.js.map +1 -1
- package/dist/tracing/TracingLogger.js +22 -0
- package/dist/tracing/TracingLogger.js.map +1 -1
- package/dist/tracing/createStore.js +51 -22
- package/dist/tracing/createStore.js.map +1 -1
- package/dist/tracing/types.d.ts +22 -0
- package/dist/types/GlobalOptions.d.ts +5 -7
- package/dist/workflow/WorkflowNormalizer.js +63 -0
- package/dist/workflow/WorkflowNormalizer.js.map +1 -1
- package/package.json +7 -4
- package/dist/cache/NodeResultCache.d.ts +0 -286
- package/dist/cache/NodeResultCache.js +0 -506
- package/dist/cache/NodeResultCache.js.map +0 -1
- package/dist/cache/index.d.ts +0 -1
- package/dist/cache/index.js +0 -2
- package/dist/cache/index.js.map +0 -1
- package/dist/concurrency/ConcurrencyBackend.d.ts +0 -61
- package/dist/concurrency/ConcurrencyBackend.js +0 -20
- package/dist/concurrency/ConcurrencyBackend.js.map +0 -1
- package/dist/concurrency/NatsKvConcurrencyBackend.d.ts +0 -64
- package/dist/concurrency/NatsKvConcurrencyBackend.js +0 -310
- package/dist/concurrency/NatsKvConcurrencyBackend.js.map +0 -1
- package/dist/concurrency/RedisConcurrencyBackend.d.ts +0 -64
- package/dist/concurrency/RedisConcurrencyBackend.js +0 -374
- package/dist/concurrency/RedisConcurrencyBackend.js.map +0 -1
- package/dist/concurrency/createConcurrencyBackend.d.ts +0 -24
- package/dist/concurrency/createConcurrencyBackend.js +0 -38
- package/dist/concurrency/createConcurrencyBackend.js.map +0 -1
- package/dist/graphql/GraphQLSchemaGenerator.d.ts +0 -129
- package/dist/graphql/GraphQLSchemaGenerator.js +0 -425
- package/dist/graphql/GraphQLSchemaGenerator.js.map +0 -1
- package/dist/integrations/APMIntegration.d.ts +0 -141
- package/dist/integrations/APMIntegration.js +0 -212
- package/dist/integrations/APMIntegration.js.map +0 -1
- package/dist/integrations/AzureMonitorIntegration.d.ts +0 -118
- package/dist/integrations/AzureMonitorIntegration.js +0 -254
- package/dist/integrations/AzureMonitorIntegration.js.map +0 -1
- package/dist/integrations/CloudWatchIntegration.d.ts +0 -135
- package/dist/integrations/CloudWatchIntegration.js +0 -293
- package/dist/integrations/CloudWatchIntegration.js.map +0 -1
- package/dist/integrations/SentryIntegration.d.ts +0 -153
- package/dist/integrations/SentryIntegration.js +0 -200
- package/dist/integrations/SentryIntegration.js.map +0 -1
- package/dist/integrations/index.d.ts +0 -19
- package/dist/integrations/index.js +0 -16
- package/dist/integrations/index.js.map +0 -1
- package/dist/marketplace/RuntimeAutoScaler.d.ts +0 -148
- package/dist/marketplace/RuntimeAutoScaler.js +0 -366
- package/dist/marketplace/RuntimeAutoScaler.js.map +0 -1
- package/dist/marketplace/RuntimeCatalog.d.ts +0 -180
- package/dist/marketplace/RuntimeCatalog.js +0 -339
- package/dist/marketplace/RuntimeCatalog.js.map +0 -1
- package/dist/marketplace/RuntimeDiscovery.d.ts +0 -86
- package/dist/marketplace/RuntimeDiscovery.js +0 -231
- package/dist/marketplace/RuntimeDiscovery.js.map +0 -1
- package/dist/marketplace/RuntimeHealthMonitor.d.ts +0 -100
- package/dist/marketplace/RuntimeHealthMonitor.js +0 -241
- package/dist/marketplace/RuntimeHealthMonitor.js.map +0 -1
- package/dist/marketplace/RuntimeMetricsDashboard.d.ts +0 -113
- package/dist/marketplace/RuntimeMetricsDashboard.js +0 -293
- package/dist/marketplace/RuntimeMetricsDashboard.js.map +0 -1
- package/dist/openapi/OpenAPIGenerator.d.ts +0 -192
- package/dist/openapi/OpenAPIGenerator.js +0 -378
- package/dist/openapi/OpenAPIGenerator.js.map +0 -1
- package/dist/openapi/index.d.ts +0 -20
- package/dist/openapi/index.js +0 -20
- package/dist/openapi/index.js.map +0 -1
- package/dist/scheduling/DebounceBackend.d.ts +0 -108
- package/dist/scheduling/DebounceBackend.js +0 -23
- package/dist/scheduling/DebounceBackend.js.map +0 -1
- package/dist/scheduling/NatsKvDebounceBackend.d.ts +0 -53
- package/dist/scheduling/NatsKvDebounceBackend.js +0 -334
- package/dist/scheduling/NatsKvDebounceBackend.js.map +0 -1
- package/dist/scheduling/RedisDebounceBackend.d.ts +0 -49
- package/dist/scheduling/RedisDebounceBackend.js +0 -356
- package/dist/scheduling/RedisDebounceBackend.js.map +0 -1
- package/dist/scheduling/createDebounceBackend.d.ts +0 -25
- package/dist/scheduling/createDebounceBackend.js +0 -39
- package/dist/scheduling/createDebounceBackend.js.map +0 -1
- package/dist/security/ABAC.d.ts +0 -224
- package/dist/security/ABAC.js +0 -380
- package/dist/security/ABAC.js.map +0 -1
- package/dist/security/AuditLogger.d.ts +0 -242
- package/dist/security/AuditLogger.js +0 -317
- package/dist/security/AuditLogger.js.map +0 -1
- package/dist/security/AuthMiddleware.d.ts +0 -162
- package/dist/security/AuthMiddleware.js +0 -289
- package/dist/security/AuthMiddleware.js.map +0 -1
- package/dist/security/EncryptionAtRest.d.ts +0 -206
- package/dist/security/EncryptionAtRest.js +0 -236
- package/dist/security/EncryptionAtRest.js.map +0 -1
- package/dist/security/OAuthProvider.d.ts +0 -334
- package/dist/security/OAuthProvider.js +0 -719
- package/dist/security/OAuthProvider.js.map +0 -1
- package/dist/security/PIIDetector.d.ts +0 -233
- package/dist/security/PIIDetector.js +0 -354
- package/dist/security/PIIDetector.js.map +0 -1
- package/dist/security/RBAC.d.ts +0 -143
- package/dist/security/RBAC.js +0 -285
- package/dist/security/RBAC.js.map +0 -1
- package/dist/security/SecretManager.d.ts +0 -652
- package/dist/security/SecretManager.js +0 -1147
- package/dist/security/SecretManager.js.map +0 -1
- package/dist/security/TLSConfig.d.ts +0 -305
- package/dist/security/TLSConfig.js +0 -550
- package/dist/security/TLSConfig.js.map +0 -1
- package/dist/security/index.d.ts +0 -81
- package/dist/security/index.js +0 -82
- package/dist/security/index.js.map +0 -1
package/dist/Blok.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { type Schema } from "jsonschema";
|
|
|
3
3
|
import type { IBlokResponse } from "./BlokResponse";
|
|
4
4
|
import type Condition from "./types/Condition";
|
|
5
5
|
import type JsonLikeObject from "./types/JsonLikeObject";
|
|
6
|
+
/** Test-only: drop the cached node instruments so a fresh MeterProvider is picked up. */
|
|
7
|
+
export declare function _resetNodeInstrumentsForTests(): void;
|
|
6
8
|
export default abstract class BlokService<T> extends NodeBase {
|
|
7
9
|
inputSchema: Schema;
|
|
8
10
|
outputSchema: Schema;
|
package/dist/Blok.js
CHANGED
|
@@ -3,6 +3,33 @@ import { metrics } from "@opentelemetry/api";
|
|
|
3
3
|
import { Validator } from "jsonschema";
|
|
4
4
|
import _ from "lodash";
|
|
5
5
|
import { applyStepOutput } from "./workflow/PersistenceHelper";
|
|
6
|
+
let _nodeInstruments = null;
|
|
7
|
+
function nodeInstruments() {
|
|
8
|
+
if (!_nodeInstruments) {
|
|
9
|
+
const meter = metrics.getMeter("blok");
|
|
10
|
+
_nodeInstruments = {
|
|
11
|
+
executions: meter.createCounter("blok_node_executions_total", {
|
|
12
|
+
description: "Total node executions",
|
|
13
|
+
unit: "1",
|
|
14
|
+
}),
|
|
15
|
+
duration: meter.createHistogram("blok_node_duration_seconds", {
|
|
16
|
+
description: "Node execution duration in seconds",
|
|
17
|
+
unit: "s",
|
|
18
|
+
}),
|
|
19
|
+
errors: meter.createCounter("blok_node_errors_total", { description: "Total node execution errors", unit: "1" }),
|
|
20
|
+
memory: meter.createGauge("blok_node_memory_bytes", {
|
|
21
|
+
description: "Peak node heap memory, in bytes",
|
|
22
|
+
unit: "By",
|
|
23
|
+
}),
|
|
24
|
+
cpu: meter.createGauge("blok_node_cpu_usage", { description: "Node CPU usage", unit: "1" }),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return _nodeInstruments;
|
|
28
|
+
}
|
|
29
|
+
/** Test-only: drop the cached node instruments so a fresh MeterProvider is picked up. */
|
|
30
|
+
export function _resetNodeInstrumentsForTests() {
|
|
31
|
+
_nodeInstruments = null;
|
|
32
|
+
}
|
|
6
33
|
export default class BlokService extends NodeBase {
|
|
7
34
|
inputSchema;
|
|
8
35
|
outputSchema;
|
|
@@ -24,42 +51,12 @@ export default class BlokService extends NodeBase {
|
|
|
24
51
|
};
|
|
25
52
|
}
|
|
26
53
|
async run(ctx) {
|
|
27
|
-
const
|
|
54
|
+
const inst = nodeInstruments();
|
|
28
55
|
const globalMetrics = new Metrics();
|
|
29
56
|
globalMetrics.start();
|
|
30
57
|
const response = { success: true, data: {}, error: null };
|
|
31
58
|
const start = performance.now();
|
|
32
59
|
ctx.logger.log(`Running node: ${this.name} [${JSON.stringify(this.originalConfig)}]`);
|
|
33
|
-
const node_execution = defaultMeter.createCounter("node", {
|
|
34
|
-
description: "Node requests",
|
|
35
|
-
});
|
|
36
|
-
const node_time = defaultMeter.createGauge("node_time", {
|
|
37
|
-
description: "Node elapsed time",
|
|
38
|
-
});
|
|
39
|
-
const node_mem = defaultMeter.createGauge("node_memory", {
|
|
40
|
-
description: "Node memory usage",
|
|
41
|
-
});
|
|
42
|
-
const node_mem_average = defaultMeter.createGauge("node_memory_average", {
|
|
43
|
-
description: "Node memory average",
|
|
44
|
-
});
|
|
45
|
-
const node_memory_usage_min = defaultMeter.createGauge("node_memory_usage_min", {
|
|
46
|
-
description: "Node memory usage min",
|
|
47
|
-
});
|
|
48
|
-
const node_memory_total = defaultMeter.createGauge("node_memory_total", {
|
|
49
|
-
description: "Node memory total",
|
|
50
|
-
});
|
|
51
|
-
const node_memory_free = defaultMeter.createGauge("node_memory_free", {
|
|
52
|
-
description: "Node memory free",
|
|
53
|
-
});
|
|
54
|
-
const node_cpu = defaultMeter.createGauge("node_cpu", {
|
|
55
|
-
description: "Node cpu usage",
|
|
56
|
-
});
|
|
57
|
-
const node_cpu_average = defaultMeter.createGauge("node_cpu_average", {
|
|
58
|
-
description: "Node cpu average",
|
|
59
|
-
});
|
|
60
|
-
const node_cpu_total = defaultMeter.createGauge("node_cpu_total", {
|
|
61
|
-
description: "Node cpu total",
|
|
62
|
-
});
|
|
63
60
|
const config = _.cloneDeep(ctx.config);
|
|
64
61
|
let opts = config[this.name];
|
|
65
62
|
const data = ctx.response?.data || ctx.request?.body;
|
|
@@ -79,20 +76,19 @@ export default class BlokService extends NodeBase {
|
|
|
79
76
|
// method use it consistently.
|
|
80
77
|
const blokResponse = result;
|
|
81
78
|
const errored = blokResponse.error !== undefined && blokResponse.error !== null;
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
// Per-node metrics on the `blok` meter. Duration is in seconds
|
|
80
|
+
// (Prometheus histogram convention).
|
|
81
|
+
const blokNodeAttrs = {
|
|
82
|
+
env: process.env.NODE_ENV ?? "development",
|
|
84
83
|
workflow_path: `${ctx.workflow_path}`,
|
|
85
84
|
workflow_name: `${ctx.workflow_name}`,
|
|
86
85
|
node_name: `${this.name}`,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
node_name: `${this.name}`,
|
|
94
|
-
node: this.node,
|
|
95
|
-
});
|
|
86
|
+
};
|
|
87
|
+
inst.executions.add(1, blokNodeAttrs);
|
|
88
|
+
inst.duration.record((end - start) / 1000, blokNodeAttrs);
|
|
89
|
+
if (errored) {
|
|
90
|
+
inst.errors.add(1, blokNodeAttrs);
|
|
91
|
+
}
|
|
96
92
|
// Surface failures clearly on the per-node log so operators don't
|
|
97
93
|
// see a misleading "Executed node" line followed by a contradictory
|
|
98
94
|
// "FAILED" line from RunnerSteps. The structured per-step log
|
|
@@ -127,75 +123,11 @@ export default class BlokService extends NodeBase {
|
|
|
127
123
|
globalMetrics.retry();
|
|
128
124
|
globalMetrics.stop();
|
|
129
125
|
const average = await globalMetrics.getMetrics();
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
node_name: `${this.name}`,
|
|
135
|
-
node: this.node,
|
|
136
|
-
});
|
|
137
|
-
node_mem_average.record(average.memory.total, {
|
|
138
|
-
env: process.env.NODE_ENV,
|
|
139
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
140
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
141
|
-
node_name: `${this.name}`,
|
|
142
|
-
node: this.node,
|
|
143
|
-
});
|
|
144
|
-
node_memory_usage_min.record(average.memory.min, {
|
|
145
|
-
env: process.env.NODE_ENV,
|
|
146
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
147
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
148
|
-
node_name: `${this.name}`,
|
|
149
|
-
node: this.node,
|
|
150
|
-
});
|
|
151
|
-
node_memory_total.record(average.memory.global_memory, {
|
|
152
|
-
env: process.env.NODE_ENV,
|
|
153
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
154
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
155
|
-
node_name: `${this.name}`,
|
|
156
|
-
node: this.node,
|
|
157
|
-
});
|
|
158
|
-
node_memory_free.record(average.memory.global_free_memory, {
|
|
159
|
-
env: process.env.NODE_ENV,
|
|
160
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
161
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
162
|
-
node_name: `${this.name}`,
|
|
163
|
-
node: this.node,
|
|
164
|
-
});
|
|
165
|
-
node_cpu.record(average.cpu.usage, {
|
|
166
|
-
env: process.env.NODE_ENV,
|
|
167
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
168
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
169
|
-
node_name: `${this.name}`,
|
|
170
|
-
node: this.node,
|
|
171
|
-
});
|
|
172
|
-
node_cpu_average.record(average.cpu.average, {
|
|
173
|
-
env: process.env.NODE_ENV,
|
|
174
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
175
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
176
|
-
node_name: `${this.name}`,
|
|
177
|
-
node: this.node,
|
|
178
|
-
});
|
|
179
|
-
node_cpu_total.record(average.cpu.total, {
|
|
180
|
-
env: process.env.NODE_ENV,
|
|
181
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
182
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
183
|
-
node_name: `${this.name}`,
|
|
184
|
-
node: this.node,
|
|
185
|
-
});
|
|
126
|
+
// `average.memory.max` is MB (MemoryUsage divides heapUsed by 1e6);
|
|
127
|
+
// re-expand to bytes for the Prometheus base-unit `_bytes` convention.
|
|
128
|
+
inst.memory.record(average.memory.max * 1_000_000, blokNodeAttrs);
|
|
129
|
+
inst.cpu.record(average.cpu.usage, blokNodeAttrs);
|
|
186
130
|
globalMetrics.clear();
|
|
187
|
-
if (response.success === false) {
|
|
188
|
-
const node_errors = defaultMeter.createCounter("node_errors", {
|
|
189
|
-
description: "Node errors",
|
|
190
|
-
});
|
|
191
|
-
node_errors.add(1, {
|
|
192
|
-
env: process.env.NODE_ENV,
|
|
193
|
-
workflow_path: `${ctx.workflow_path}`,
|
|
194
|
-
workflow_name: `${ctx.workflow_name}`,
|
|
195
|
-
node_name: `${this.name}`,
|
|
196
|
-
node: this.node,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
131
|
return response;
|
|
200
132
|
}
|
|
201
133
|
async validate(obj, schema) {
|
package/dist/Blok.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blok.js","sourceRoot":"","sources":["../src/Blok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,OAAO,EAAE,QAAQ,EAAwB,MAAM,gBAAgB,CAAC;AAE3G,OAAO,
|
|
1
|
+
{"version":3,"file":"Blok.js","sourceRoot":"","sources":["../src/Blok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,OAAO,EAAE,QAAQ,EAAwB,MAAM,gBAAgB,CAAC;AAE3G,OAAO,EAA4C,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAqC,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,CAAC,MAAM,QAAQ,CAAC;AAIvB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAkB/D,IAAI,gBAAgB,GAA2B,IAAI,CAAC;AACpD,SAAS,eAAe;IACvB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvC,gBAAgB,GAAG;YAClB,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,4BAA4B,EAAE;gBAC7D,WAAW,EAAE,uBAAuB;gBACpC,IAAI,EAAE,GAAG;aACT,CAAC;YACF,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,4BAA4B,EAAE;gBAC7D,WAAW,EAAE,oCAAoC;gBACjD,IAAI,EAAE,GAAG;aACT,CAAC;YACF,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,wBAAwB,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;YAChH,MAAM,EAAE,KAA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BAChD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACnD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC;IACF,CAAC;CACD"}
|
package/dist/DefaultLogger.d.ts
CHANGED
|
@@ -25,6 +25,19 @@ export default class DefaultLogger extends GlobalLogger {
|
|
|
25
25
|
* The name of the application.
|
|
26
26
|
*/
|
|
27
27
|
appName: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* OBS-03 — correlation keys. `runId` ties a stdout line to the Studio run;
|
|
30
|
+
* `traceId`/`spanId` tie it to the OTel trace in Tempo. Set by `TracingLogger`
|
|
31
|
+
* after `tracker.startRun()` (run id) + from the active span (trace ids), so
|
|
32
|
+
* Studio ↔ Tempo ↔ Loki become one joined view. Unset → simply omitted.
|
|
33
|
+
*/
|
|
34
|
+
runId: string | undefined;
|
|
35
|
+
traceId: string | undefined;
|
|
36
|
+
spanId: string | undefined;
|
|
37
|
+
/** OBS-03 — set the Studio run id on subsequent log lines. */
|
|
38
|
+
setRunId(runId?: string): void;
|
|
39
|
+
/** OBS-03 — set the active OTel trace/span ids on subsequent log lines. */
|
|
40
|
+
setTraceContext(traceId?: string, spanId?: string): void;
|
|
28
41
|
/**
|
|
29
42
|
* Constructs a new DefaultLogger instance.
|
|
30
43
|
*
|
package/dist/DefaultLogger.js
CHANGED
|
@@ -25,6 +25,24 @@ export default class DefaultLogger extends GlobalLogger {
|
|
|
25
25
|
* The name of the application.
|
|
26
26
|
*/
|
|
27
27
|
appName = "";
|
|
28
|
+
/**
|
|
29
|
+
* OBS-03 — correlation keys. `runId` ties a stdout line to the Studio run;
|
|
30
|
+
* `traceId`/`spanId` tie it to the OTel trace in Tempo. Set by `TracingLogger`
|
|
31
|
+
* after `tracker.startRun()` (run id) + from the active span (trace ids), so
|
|
32
|
+
* Studio ↔ Tempo ↔ Loki become one joined view. Unset → simply omitted.
|
|
33
|
+
*/
|
|
34
|
+
runId = undefined;
|
|
35
|
+
traceId = undefined;
|
|
36
|
+
spanId = undefined;
|
|
37
|
+
/** OBS-03 — set the Studio run id on subsequent log lines. */
|
|
38
|
+
setRunId(runId) {
|
|
39
|
+
this.runId = runId;
|
|
40
|
+
}
|
|
41
|
+
/** OBS-03 — set the active OTel trace/span ids on subsequent log lines. */
|
|
42
|
+
setTraceContext(traceId, spanId) {
|
|
43
|
+
this.traceId = traceId;
|
|
44
|
+
this.spanId = spanId;
|
|
45
|
+
}
|
|
28
46
|
/**
|
|
29
47
|
* Constructs a new DefaultLogger instance.
|
|
30
48
|
*
|
|
@@ -93,6 +111,13 @@ export default class DefaultLogger extends GlobalLogger {
|
|
|
93
111
|
logEntry.workflow_path = this.workflowPath;
|
|
94
112
|
if (this.requestId)
|
|
95
113
|
logEntry.request_id = this.requestId;
|
|
114
|
+
// OBS-03 — correlation keys so a log line joins to its Studio run + Tempo trace.
|
|
115
|
+
if (this.runId)
|
|
116
|
+
logEntry.run_id = this.runId;
|
|
117
|
+
if (this.traceId)
|
|
118
|
+
logEntry.trace_id = this.traceId;
|
|
119
|
+
if (this.spanId)
|
|
120
|
+
logEntry.span_id = this.spanId;
|
|
96
121
|
if (stack !== "")
|
|
97
122
|
logEntry.stack = stack;
|
|
98
123
|
return JSON.stringify(logEntry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultLogger.js","sourceRoot":"","sources":["../src/DefaultLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,YAAY;IACtD;;OAEG;IACH,YAAY,GAAuB,EAAE,CAAC;IAEtC;;OAEG;IACH,YAAY,GAAuB,EAAE,CAAC;IAEtC;;OAEG;IACH,SAAS,GAAuB,EAAE,CAAC;IAEn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OAAO;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,OAAO;SACP,CAAC;QAEF,IAAI,IAAI,CAAC,YAAY;YAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC;QAClE,IAAI,IAAI,CAAC,YAAY;YAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC;QAClE,IAAI,IAAI,CAAC,SAAS;YAAE,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACzD,iFAAiF;QACjF,IAAI,IAAI,CAAC,KAAK;YAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,IAAI,IAAI,CAAC,OAAO;YAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QACnD,IAAI,IAAI,CAAC,MAAM;YAAE,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAChD,IAAI,KAAK,KAAK,EAAE;YAAE,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAEzC,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD"}
|
package/dist/RunnerSteps.d.ts
CHANGED
|
@@ -11,4 +11,27 @@ export default abstract class RunnerSteps {
|
|
|
11
11
|
* @throws {GlobalError} Throws a GlobalError if any step results in an error.
|
|
12
12
|
*/
|
|
13
13
|
runSteps(ctx: Context, steps: NodeBase[], deep?: boolean, step_name?: string): Promise<Context>;
|
|
14
|
+
/**
|
|
15
|
+
* PR 4 — wait.for / wait.until resume cursor.
|
|
16
|
+
*
|
|
17
|
+
* On `dispatchDeferred` re-entry from a wait step, the runner must skip
|
|
18
|
+
* past pre-wait steps that already completed in the previous pass.
|
|
19
|
+
* `lastCompletedStepIndex` is set on the run record before each
|
|
20
|
+
* WaitDispatchRequest throw and read here at runSteps entry. Default
|
|
21
|
+
* `-1` = no resume; runner starts at i = 0. Extracted verbatim from the
|
|
22
|
+
* top of `runSteps` (E06-T002) — the only mutation is clearing the
|
|
23
|
+
* `_blokInnerResumeIndex` sentinel.
|
|
24
|
+
*/
|
|
25
|
+
private resolveResumeCursor;
|
|
26
|
+
/**
|
|
27
|
+
* Unwrap + enrich a caught error into a `GlobalError`: walk the
|
|
28
|
+
* `.cause` chain looking for an inner `GlobalError` (so an author's
|
|
29
|
+
* structured rejection survives the framework's `[step N/M] X
|
|
30
|
+
* failed: ...` wrap), otherwise build a fresh `GlobalError` that
|
|
31
|
+
* preserves the original chain via `.cause`, then stamp the wrap's
|
|
32
|
+
* `_blokStepId` back on so `TryCatchNode.toErrorEnvelope` can surface
|
|
33
|
+
* it as `$.error.stepId`. Pure — no ctx mutation. Extracted verbatim
|
|
34
|
+
* from the `runSteps` catch arm (E06-T002).
|
|
35
|
+
*/
|
|
36
|
+
private unwrapAndEnrichError;
|
|
14
37
|
}
|
package/dist/RunnerSteps.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GlobalError } from "@blokjs/shared";
|
|
2
|
+
import { SpanKind, SpanStatusCode, context, trace } from "@opentelemetry/api";
|
|
2
3
|
import { RunCancelledError } from "./RunCancelledError";
|
|
3
4
|
import { WaitDispatchRequest } from "./WaitDispatchRequest";
|
|
4
5
|
import { resolveIdempotencyKey } from "./idempotency/resolveIdempotencyKey";
|
|
@@ -13,6 +14,12 @@ import { applyStepOutput } from "./workflow/PersistenceHelper";
|
|
|
13
14
|
* default and the decision recorded in the Tier 1 ROADMAP session.
|
|
14
15
|
*/
|
|
15
16
|
const DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1000;
|
|
17
|
+
/**
|
|
18
|
+
* OBS-02 B4 — module-level tracer for per-step child spans. Returns a no-op
|
|
19
|
+
* tracer (zero overhead) until a real TracerProvider is registered at trigger
|
|
20
|
+
* boot, so free-running deployments are unaffected.
|
|
21
|
+
*/
|
|
22
|
+
const stepTracer = trace.getTracer("@blokjs/runner.steps", "1.0.0");
|
|
16
23
|
/**
|
|
17
24
|
* Compute the delay before retry attempt N+1 using capped exponential
|
|
18
25
|
* backoff. Mirrors Trigger.dev's `retry` semantics — no jitter by default.
|
|
@@ -129,35 +136,7 @@ export default class RunnerSteps {
|
|
|
129
136
|
let flow_steps = [];
|
|
130
137
|
let flow_step = 0;
|
|
131
138
|
let stepName = "";
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
// On `dispatchDeferred` re-entry from a wait step, the runner
|
|
135
|
-
// must skip past pre-wait steps that already completed in the
|
|
136
|
-
// previous pass. `lastCompletedStepIndex` is set on the run
|
|
137
|
-
// record before each WaitDispatchRequest throw and read here
|
|
138
|
-
// at runSteps entry. Default `-1` = no resume; runner starts
|
|
139
|
-
// at i = 0.
|
|
140
|
-
const persistedRun = !deep && tracker && traceRunId ? tracker.getStore().getRun(traceRunId) : undefined;
|
|
141
|
-
// Two cursor sources:
|
|
142
|
-
// - Top-level (deep === false): workflow_runs.lastCompletedStepIndex.
|
|
143
|
-
// - Nested inside a primitive iterator (deep === true, v0.6
|
|
144
|
-
// Phase 2): `_blokInnerResumeIndex` stamped on the child ctx
|
|
145
|
-
// by ForEachNode.runIteration when resuming at a specific
|
|
146
|
-
// inner step. Undefined = start at 0 (fresh iteration body).
|
|
147
|
-
const innerResumeIndexRaw = ctx._blokInnerResumeIndex;
|
|
148
|
-
const innerResumeIndex = typeof innerResumeIndexRaw === "number" ? innerResumeIndexRaw : undefined;
|
|
149
|
-
const resumeFromIndex = !deep
|
|
150
|
-
? persistedRun?.lastCompletedStepIndex !== undefined
|
|
151
|
-
? persistedRun.lastCompletedStepIndex + 1
|
|
152
|
-
: 0
|
|
153
|
-
: (innerResumeIndex ?? 0);
|
|
154
|
-
// Clear the sentinel so a re-runner started fresh from this
|
|
155
|
-
// childCtx (e.g. the nested branch flow path) doesn't inherit
|
|
156
|
-
// a stale resume hint. ForEachNode set it for THIS one re-entry
|
|
157
|
-
// only; it should not propagate further.
|
|
158
|
-
if (deep && innerResumeIndex !== undefined) {
|
|
159
|
-
ctx._blokInnerResumeIndex = undefined;
|
|
160
|
-
}
|
|
139
|
+
const { resumeFromIndex, persistedRun, innerResumeIndex } = this.resolveResumeCursor(ctx, deep, tracker, traceRunId);
|
|
161
140
|
for (let i = 0; i < steps.length; i++) {
|
|
162
141
|
const step = steps[i];
|
|
163
142
|
// PR 4 — skip pre-wait steps on resume. State + NodeRuns
|
|
@@ -551,16 +530,31 @@ export default class RunnerSteps {
|
|
|
551
530
|
// finally). The Phase 2/3 single-slot
|
|
552
531
|
// `_blokActivePrimitiveNodeRunId` mechanism is gone —
|
|
553
532
|
// nested primitives each register their own frame, and
|
|
554
|
-
// the wait-throw site walks the full stack.
|
|
555
|
-
//
|
|
556
|
-
//
|
|
557
|
-
//
|
|
558
|
-
|
|
533
|
+
// the wait-throw site walks the full stack.
|
|
534
|
+
// === OBS-02 B4 — per-step OTel child span ===
|
|
535
|
+
// One span per EXECUTING leaf step, nested under the workflow span.
|
|
536
|
+
// `wait` + idempotency-cache-hit steps continue above this point, so only
|
|
537
|
+
// steps that actually invoke process() reach here. Made active around
|
|
538
|
+
// process() so a gRPC runtime call / http-self sub-workflow dispatch
|
|
539
|
+
// (B2.2/B2.3) nests beneath it. No-op + zero overhead when no provider
|
|
540
|
+
// is registered (OTel API guarantee).
|
|
541
|
+
const stepSpan = stepTracer.startSpan(`step ${step.name}`, {
|
|
542
|
+
kind: SpanKind.INTERNAL,
|
|
543
|
+
attributes: {
|
|
544
|
+
"blok.step.id": step.name,
|
|
545
|
+
"blok.step.index": i,
|
|
546
|
+
"blok.node.name": step.name,
|
|
547
|
+
"blok.node.type": stepType,
|
|
548
|
+
...(stepAny.runtime ? { "blok.runtime.kind": stepAny.runtime } : {}),
|
|
549
|
+
},
|
|
550
|
+
});
|
|
559
551
|
try {
|
|
560
552
|
while (true) {
|
|
561
553
|
attempt += 1;
|
|
562
554
|
try {
|
|
563
|
-
|
|
555
|
+
// Run process() inside the step span's context so child spans
|
|
556
|
+
// (gRPC runtime / sub-workflow dispatch) nest under it.
|
|
557
|
+
const processInvocation = () => context.with(trace.setSpan(context.active(), stepSpan), () => step.process(ctx, step));
|
|
564
558
|
const model = typeof maxDurationMs === "number" && maxDurationMs > 0
|
|
565
559
|
? await wrapWithTimeout(processInvocation, maxDurationMs, step.name)
|
|
566
560
|
: await processInvocation();
|
|
@@ -612,6 +606,7 @@ export default class RunnerSteps {
|
|
|
612
606
|
}
|
|
613
607
|
const attemptSuffix = attempt > 1 ? ` after ${attempt} attempts` : "";
|
|
614
608
|
ctx.logger.log(`${stepPrefix} → completed (${stepDuration}ms${attemptSuffix})`);
|
|
609
|
+
stepSpan.setStatus({ code: SpanStatusCode.OK });
|
|
615
610
|
break;
|
|
616
611
|
}
|
|
617
612
|
catch (nodeErr) {
|
|
@@ -680,18 +675,16 @@ export default class RunnerSteps {
|
|
|
680
675
|
const enrichedAny = enrichedError;
|
|
681
676
|
enrichedAny.cause = nodeErr;
|
|
682
677
|
enrichedAny._blokStepId = step.name;
|
|
678
|
+
stepSpan.recordException(nodeErr instanceof Error ? nodeErr : new Error(String(nodeErr)));
|
|
679
|
+
stepSpan.setStatus({ code: SpanStatusCode.ERROR, message: originalMsg });
|
|
683
680
|
throw enrichedError;
|
|
684
681
|
}
|
|
685
682
|
}
|
|
686
683
|
}
|
|
687
684
|
finally {
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
-
|
|
691
|
-
// `isIteratingPrimitive` flag stays in the type
|
|
692
|
-
// system for documentation but no longer drives
|
|
693
|
-
// cursor accounting.
|
|
694
|
-
void isIteratingPrimitive;
|
|
685
|
+
// OBS-02 B4 — close the per-step span on every exit (success / failure /
|
|
686
|
+
// wait / cancel / timeout).
|
|
687
|
+
stepSpan.end();
|
|
695
688
|
}
|
|
696
689
|
}
|
|
697
690
|
else {
|
|
@@ -733,55 +726,103 @@ export default class RunnerSteps {
|
|
|
733
726
|
const wrapStepId = typeof e === "object" && e !== null && "_blokStepId" in e
|
|
734
727
|
? e._blokStepId
|
|
735
728
|
: undefined;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
729
|
+
throw this.unwrapAndEnrichError(e, wrapStepId);
|
|
730
|
+
}
|
|
731
|
+
return ctx;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* PR 4 — wait.for / wait.until resume cursor.
|
|
735
|
+
*
|
|
736
|
+
* On `dispatchDeferred` re-entry from a wait step, the runner must skip
|
|
737
|
+
* past pre-wait steps that already completed in the previous pass.
|
|
738
|
+
* `lastCompletedStepIndex` is set on the run record before each
|
|
739
|
+
* WaitDispatchRequest throw and read here at runSteps entry. Default
|
|
740
|
+
* `-1` = no resume; runner starts at i = 0. Extracted verbatim from the
|
|
741
|
+
* top of `runSteps` (E06-T002) — the only mutation is clearing the
|
|
742
|
+
* `_blokInnerResumeIndex` sentinel.
|
|
743
|
+
*/
|
|
744
|
+
resolveResumeCursor(ctx, deep, tracker, traceRunId) {
|
|
745
|
+
const persistedRun = !deep && tracker && traceRunId ? tracker.getStore().getRun(traceRunId) : undefined;
|
|
746
|
+
// Two cursor sources:
|
|
747
|
+
// - Top-level (deep === false): workflow_runs.lastCompletedStepIndex.
|
|
748
|
+
// - Nested inside a primitive iterator (deep === true, v0.6
|
|
749
|
+
// Phase 2): `_blokInnerResumeIndex` stamped on the child ctx
|
|
750
|
+
// by ForEachNode.runIteration when resuming at a specific
|
|
751
|
+
// inner step. Undefined = start at 0 (fresh iteration body).
|
|
752
|
+
const innerResumeIndexRaw = ctx._blokInnerResumeIndex;
|
|
753
|
+
const innerResumeIndex = typeof innerResumeIndexRaw === "number" ? innerResumeIndexRaw : undefined;
|
|
754
|
+
const resumeFromIndex = !deep
|
|
755
|
+
? persistedRun?.lastCompletedStepIndex !== undefined
|
|
756
|
+
? persistedRun.lastCompletedStepIndex + 1
|
|
757
|
+
: 0
|
|
758
|
+
: (innerResumeIndex ?? 0);
|
|
759
|
+
// Clear the sentinel so a re-runner started fresh from this
|
|
760
|
+
// childCtx (e.g. the nested branch flow path) doesn't inherit
|
|
761
|
+
// a stale resume hint. ForEachNode set it for THIS one re-entry
|
|
762
|
+
// only; it should not propagate further.
|
|
763
|
+
if (deep && innerResumeIndex !== undefined) {
|
|
764
|
+
ctx._blokInnerResumeIndex = undefined;
|
|
765
|
+
}
|
|
766
|
+
return { resumeFromIndex, persistedRun, innerResumeIndex };
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Unwrap + enrich a caught error into a `GlobalError`: walk the
|
|
770
|
+
* `.cause` chain looking for an inner `GlobalError` (so an author's
|
|
771
|
+
* structured rejection survives the framework's `[step N/M] X
|
|
772
|
+
* failed: ...` wrap), otherwise build a fresh `GlobalError` that
|
|
773
|
+
* preserves the original chain via `.cause`, then stamp the wrap's
|
|
774
|
+
* `_blokStepId` back on so `TryCatchNode.toErrorEnvelope` can surface
|
|
775
|
+
* it as `$.error.stepId`. Pure — no ctx mutation. Extracted verbatim
|
|
776
|
+
* from the `runSteps` catch arm (E06-T002).
|
|
777
|
+
*/
|
|
778
|
+
unwrapAndEnrichError(e, wrapStepId) {
|
|
779
|
+
let error_context = {};
|
|
780
|
+
if (e instanceof GlobalError) {
|
|
781
|
+
error_context = e;
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
// Walk the `.cause` chain looking for a GlobalError. The
|
|
785
|
+
// step-enrichment wrap at line ~465 sets `cause = nodeErr`,
|
|
786
|
+
// and `nodeErr` may itself be a GlobalError thrown from
|
|
787
|
+
// `defineNode`-built nodes (e.g. `@blokjs/throw` setting
|
|
788
|
+
// `code: 401` for an auth-check middleware). Without this
|
|
789
|
+
// walk, the outer wrap below would force the framework's
|
|
790
|
+
// generic `[step N/M] X failed: ...` message + default 500
|
|
791
|
+
// code, clobbering the author's structured rejection.
|
|
792
|
+
let inner = e;
|
|
793
|
+
let foundGlobal = null;
|
|
794
|
+
while (typeof inner === "object" &&
|
|
795
|
+
inner !== null &&
|
|
796
|
+
"cause" in inner &&
|
|
797
|
+
inner.cause !== undefined &&
|
|
798
|
+
inner.cause !== inner) {
|
|
799
|
+
inner = inner.cause;
|
|
800
|
+
if (inner instanceof GlobalError) {
|
|
801
|
+
foundGlobal = inner;
|
|
802
|
+
break;
|
|
773
803
|
}
|
|
774
804
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
805
|
+
if (foundGlobal) {
|
|
806
|
+
error_context = foundGlobal;
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
error_context = new GlobalError(e.message);
|
|
810
|
+
// Preserve the original error chain so outer handlers
|
|
811
|
+
// (notably v0.5 TryCatchNode's `$.error.message` resolution)
|
|
812
|
+
// can peel back through `.cause` to the author's original
|
|
813
|
+
// `throw new Error("...")` text instead of the runner's
|
|
814
|
+
// `[step N/M] <name> failed: ...` enriched prefix.
|
|
815
|
+
error_context.cause = e;
|
|
781
816
|
}
|
|
782
|
-
throw error_context;
|
|
783
817
|
}
|
|
784
|
-
|
|
818
|
+
// Stamp the wrap's stepId on the unwrapped error so TryCatchNode's
|
|
819
|
+
// `toErrorEnvelope` walk can surface it as `$.error.stepId`. The
|
|
820
|
+
// inner-try wrap layer is gone by this point; this is the only
|
|
821
|
+
// place where the runner can identify which sub-step failed.
|
|
822
|
+
if (typeof wrapStepId === "string" && wrapStepId.length > 0) {
|
|
823
|
+
error_context._blokStepId = wrapStepId;
|
|
824
|
+
}
|
|
825
|
+
return error_context;
|
|
785
826
|
}
|
|
786
827
|
}
|
|
787
828
|
//# sourceMappingURL=RunnerSteps.js.map
|