@diia-inhouse/workflow 2.6.5 → 2.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.
@@ -1,5 +1,5 @@
1
1
  import { TemporalClient } from "../services/client.js";
2
- import { isNewStepsAdded } from "./determinism/errorClassifier.js";
2
+ import { isNewStepsAdded, isWorkflowNotFoundError } from "./determinism/errorClassifier.js";
3
3
  import { loadHistoryEntries } from "./determinism/historyFiles.js";
4
4
  import { DeterminismReportBuilder } from "./determinism/report.js";
5
5
  import { buildReplayOptions, resolveWorkflowsPath } from "./determinism/replayOptions.js";
@@ -160,9 +160,13 @@ var CheckWorkflowDeterminismCommand = class {
160
160
  }
161
161
  async checkSingleWorkflow(client, options, workflowId, reportBuilder) {
162
162
  this.logger.info(`Checking workflow ${workflowId}`);
163
- const handle = client.workflow.getHandle(workflowId);
164
- const history = await handle.fetchHistory();
165
- const workflowName = (await handle.describe()).type;
163
+ const fetched = await this.fetchWorkflowHistory(client, workflowId);
164
+ if (!fetched) {
165
+ reportBuilder.addSkipped();
166
+ this.logger.warn(`⚠️ Workflow ${workflowId} no longer exists on the server (likely deleted after retention) — skipping`);
167
+ return;
168
+ }
169
+ const { history, workflowName } = fetched;
166
170
  const outcome = await replaySingle(options, history, workflowId, workflowName, {
167
171
  maxRetries: this.maxRetries,
168
172
  retryDelayMs: this.retryDelayMs,
@@ -211,6 +215,18 @@ var CheckWorkflowDeterminismCommand = class {
211
215
  break;
212
216
  }
213
217
  }
218
+ async fetchWorkflowHistory(client, workflowId) {
219
+ const handle = client.workflow.getHandle(workflowId);
220
+ try {
221
+ return {
222
+ history: await handle.fetchHistory(),
223
+ workflowName: (await handle.describe()).type
224
+ };
225
+ } catch (err) {
226
+ if (isWorkflowNotFoundError(err)) return;
227
+ throw err;
228
+ }
229
+ }
214
230
  async loadWorkflows(workflowsPath) {
215
231
  const fullWorkflowsPath = resolveWorkflowsPath(workflowsPath);
216
232
  if (!existsSync(fullWorkflowsPath)) throw new Error(`Workflow files not found under provided path: ${fullWorkflowsPath}`);
@@ -1,5 +1,11 @@
1
+ import { WorkflowNotFoundError, isGrpcServiceError } from "@temporalio/client";
1
2
  import { DeterminismViolationError } from "@temporalio/workflow";
2
3
  //#region src/cli/determinism/errorClassifier.ts
4
+ const GRPC_STATUS_NOT_FOUND = 5;
5
+ function isWorkflowNotFoundError(error) {
6
+ if (error instanceof WorkflowNotFoundError) return true;
7
+ return isGrpcServiceError(error) && error.code === GRPC_STATUS_NOT_FOUND;
8
+ }
3
9
  const activityMismatchRegex = /Activity type of scheduled event '(.+?)' does not match activity type of activity command '(.+?)'/;
4
10
  function isNewStepsAdded(error) {
5
11
  return error.errorType === "DeterminismViolation" && error.errorMessage.includes("WorkflowExecutionCompleted");
@@ -58,4 +64,4 @@ function classifyReplayError(workflowId, error) {
58
64
  };
59
65
  }
60
66
  //#endregion
61
- export { classifyReplayError, isNewStepsAdded };
67
+ export { classifyReplayError, isNewStepsAdded, isWorkflowNotFoundError };
@@ -36,6 +36,9 @@ var DeterminismReportBuilder = class {
36
36
  setSkippedCount(count) {
37
37
  this.skippedCount = count;
38
38
  }
39
+ addSkipped() {
40
+ this.skippedCount++;
41
+ }
39
42
  addWarning(warning) {
40
43
  this.warnings.push(warning);
41
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diia-inhouse/workflow",
3
- "version": "2.6.5",
3
+ "version": "2.7.0",
4
4
  "description": "Workflow",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",