Skip to content

Commit 01dab75

Browse files
authored
Merge branch 'main' into activity_pause
2 parents a9a9339 + caae0a4 commit 01dab75

File tree

19 files changed

+124
-37
lines changed

19 files changed

+124
-37
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.11.5",
2+
"version": "1.12.0-rc.0",
33
"npmClient": "npm",
44
"command": {
55
"publish": {

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/activity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/activity",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK Activity sub-package",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/client",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK Client sub-package",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

packages/cloud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/cloud",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK — Temporal Cloud Client",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/common",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Common library for code that's used across the Client, Worker, and/or Workflow",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

packages/common/src/converter/failure-converter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import {
33
ApplicationFailure,
44
CancelledFailure,
55
ChildWorkflowFailure,
6+
decodeApplicationFailureCategory,
67
decodeRetryState,
78
decodeTimeoutType,
9+
encodeApplicationFailureCategory,
810
encodeRetryState,
911
encodeTimeoutType,
1012
FAILURE_SOURCE,
@@ -127,7 +129,9 @@ export class DefaultFailureConverter implements FailureConverter {
127129
failure.applicationFailureInfo.type,
128130
Boolean(failure.applicationFailureInfo.nonRetryable),
129131
arrayFromPayloads(payloadConverter, failure.applicationFailureInfo.details?.payloads),
130-
this.optionalFailureToOptionalError(failure.cause, payloadConverter)
132+
this.optionalFailureToOptionalError(failure.cause, payloadConverter),
133+
undefined,
134+
decodeApplicationFailureCategory(failure.applicationFailureInfo.category)
131135
);
132136
}
133137
if (failure.serverFailureInfo) {
@@ -273,6 +277,7 @@ export class DefaultFailureConverter implements FailureConverter {
273277
? { payloads: toPayloads(payloadConverter, ...err.details) }
274278
: undefined,
275279
nextRetryDelay: msOptionalToTs(err.nextRetryDelay),
280+
category: encodeApplicationFailureCategory(err.category),
276281
},
277282
};
278283
}

packages/common/src/failure.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,34 @@ export const [encodeRetryState, decodeRetryState] = makeProtoEnumConverters<
101101
'RETRY_STATE_'
102102
);
103103

104+
/**
105+
* A category to describe the severity and change the observability behavior of an application failure.
106+
*
107+
* Currently, observability behaviour changes are limited to:
108+
* - activities that fail due to a BENIGN application failure emit DEBUG level logs and do not record metrics
109+
*
110+
* @experimental Category is a new feature and may be subject to change.
111+
*/
112+
export const ApplicationFailureCategory = {
113+
BENIGN: 'BENIGN',
114+
} as const;
115+
116+
export type ApplicationFailureCategory = (typeof ApplicationFailureCategory)[keyof typeof ApplicationFailureCategory];
117+
118+
export const [encodeApplicationFailureCategory, decodeApplicationFailureCategory] = makeProtoEnumConverters<
119+
temporal.api.enums.v1.ApplicationErrorCategory,
120+
typeof temporal.api.enums.v1.ApplicationErrorCategory,
121+
keyof typeof temporal.api.enums.v1.ApplicationErrorCategory,
122+
typeof ApplicationFailureCategory,
123+
'APPLICATION_ERROR_CATEGORY_'
124+
>(
125+
{
126+
[ApplicationFailureCategory.BENIGN]: 1,
127+
UNSPECIFIED: 0,
128+
} as const,
129+
'APPLICATION_ERROR_CATEGORY_'
130+
);
131+
104132
export type WorkflowExecution = temporal.api.common.v1.IWorkflowExecution;
105133

106134
/**
@@ -172,7 +200,8 @@ export class ApplicationFailure extends TemporalFailure {
172200
public readonly nonRetryable?: boolean | undefined | null,
173201
public readonly details?: unknown[] | undefined | null,
174202
cause?: Error,
175-
public readonly nextRetryDelay?: Duration | undefined | null
203+
public readonly nextRetryDelay?: Duration | undefined | null,
204+
public readonly category?: ApplicationFailureCategory | undefined | null
176205
) {
177206
super(message, cause);
178207
}
@@ -195,8 +224,8 @@ export class ApplicationFailure extends TemporalFailure {
195224
* By default, will be retryable (unless its `type` is included in {@link RetryPolicy.nonRetryableErrorTypes}).
196225
*/
197226
public static create(options: ApplicationFailureOptions): ApplicationFailure {
198-
const { message, type, nonRetryable = false, details, nextRetryDelay, cause } = options;
199-
return new this(message, type, nonRetryable, details, cause, nextRetryDelay);
227+
const { message, type, nonRetryable = false, details, nextRetryDelay, cause, category } = options;
228+
return new this(message, type, nonRetryable, details, cause, nextRetryDelay, category);
200229
}
201230

202231
/**
@@ -261,6 +290,12 @@ export interface ApplicationFailureOptions {
261290
* Cause of the failure
262291
*/
263292
cause?: Error;
293+
294+
/**
295+
* Severity category of the application error.
296+
* Affects worker-side logging and metrics behavior of this failure.
297+
*/
298+
category?: ApplicationFailureCategory;
264299
}
265300

266301
/**

packages/core-bridge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/core-bridge",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK Core<>Node bridge",
55
"main": "index.js",
66
"types": "lib/index.d.ts",

packages/create-project/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/create",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Create a Temporal project from template",
55
"main": "cli.js",
66
"bin": "cli.js",

packages/interceptors-opentelemetry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/interceptors-opentelemetry",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK interceptors bundle for tracing with opentelemetry",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

packages/nyc-test-coverage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/nyc-test-coverage",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK code coverage integration",
55
"keywords": [
66
"temporal",

packages/proto/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/proto",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK compiled protobuf definitions",
55
"main": "protos/index.js",
66
"types": "protos/index.d.ts",

packages/test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@temporalio/test",
4-
"version": "1.11.5",
4+
"version": "1.12.0-rc.0",
55
"description": "Temporal.io SDK Tests",
66
"scripts": {
77
"build": "npm-run-all build:protos build:ts",

packages/test/src/test-integration-workflows-with-recorded-logs.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ExecutionContext } from 'ava';
22
import * as workflow from '@temporalio/workflow';
3-
import { HandlerUnfinishedPolicy } from '@temporalio/common';
3+
import { ApplicationFailureCategory, HandlerUnfinishedPolicy } from '@temporalio/common';
44
import { LogEntry } from '@temporalio/worker';
55
import { WorkflowFailedError, WorkflowUpdateFailedError } from '@temporalio/client';
66
import { Context, helpers, makeTestFunction } from './helpers-integration';
@@ -469,3 +469,44 @@ async function assertWorkflowUpdateFailedBecauseWorkflowCompleted(t: ExecutionCo
469469
t.true((cause as workflow.ApplicationFailure).type === 'AcceptedUpdateCompletedWorkflow');
470470
t.regex((cause as workflow.ApplicationFailure).message, /Workflow completed before the Update completed/);
471471
}
472+
473+
export async function raiseErrorWorkflow(useBenign: boolean): Promise<void> {
474+
await workflow
475+
.proxyActivities({ startToCloseTimeout: '10s', retry: { maximumAttempts: 1 } })
476+
.throwApplicationFailureActivity(useBenign);
477+
}
478+
479+
test('Application failure category controls log level', async (t) => {
480+
const { createWorker, startWorkflow } = helpers(t);
481+
const worker = await createWorker({
482+
activities: {
483+
async throwApplicationFailureActivity(useBenign: boolean) {
484+
throw workflow.ApplicationFailure.create({
485+
category: useBenign ? ApplicationFailureCategory.BENIGN : undefined,
486+
});
487+
},
488+
},
489+
});
490+
491+
await worker.runUntil(async () => {
492+
// Run with BENIGN
493+
let handle = await startWorkflow(raiseErrorWorkflow, { args: [true] });
494+
try {
495+
await handle.result();
496+
} catch (_) {
497+
const logs = recordedLogs[handle.workflowId];
498+
const activityFailureLog = logs.find((log) => log.message.includes('Activity failed'));
499+
t.true(activityFailureLog !== undefined && activityFailureLog.level === 'DEBUG');
500+
}
501+
502+
// Run without BENIGN
503+
handle = await startWorkflow(raiseErrorWorkflow, { args: [false] });
504+
try {
505+
await handle.result();
506+
} catch (_) {
507+
const logs = recordedLogs[handle.workflowId];
508+
const activityFailureLog = logs.find((log) => log.message.includes('Activity failed'));
509+
t.true(activityFailureLog !== undefined && activityFailureLog.level === 'WARN');
510+
}
511+
});
512+
});

packages/testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/testing",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK Testing sub-package",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

packages/worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/worker",
3-
"version": "1.11.5",
3+
"version": "1.12.0-rc.0",
44
"description": "Temporal.io SDK Worker sub-package",
55
"main": "lib/index.js",
66
"types": "./lib/index.d.ts",

0 commit comments

Comments
 (0)