Skip to content

Commit 582e4f0

Browse files
committed
add logging for activity pause, emit application failure on activity pause
1 parent 8787f57 commit 582e4f0

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

packages/worker/src/activity.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ export class Activity {
143143
(error instanceof CancelledFailure || isAbortError(error)) &&
144144
this.context.cancellationSignal.aborted
145145
) {
146-
this.workerLogger.debug('Activity completed as cancelled', { durationMs });
146+
if (this.context.cancellationDetails.details?.paused) {
147+
this.workerLogger.debug('Activity paused', { durationMs });
148+
} else {
149+
this.workerLogger.debug('Activity completed as cancelled', { durationMs });
150+
}
147151
} else if (error instanceof CompleteAsyncError) {
148152
this.workerLogger.debug('Activity will complete asynchronously', { durationMs });
149153
} else {
@@ -176,9 +180,21 @@ export class Activity {
176180
} else if (this.cancelReason) {
177181
// Either a CancelledFailure that we threw or AbortError from AbortController
178182
if (err instanceof CancelledFailure) {
179-
const failure = await encodeErrorToFailure(this.dataConverter, err);
180-
failure.stackTrace = undefined;
181-
return { cancelled: { failure } };
183+
// If cancel due to activity pause, emit an application failure for the pause.
184+
if (this.context.cancellationDetails.details?.paused) {
185+
return {
186+
failed: {
187+
failure: await encodeErrorToFailure(
188+
this.dataConverter,
189+
new ApplicationFailure('Activity paused', 'ActivityPause')
190+
),
191+
},
192+
};
193+
} else {
194+
const failure = await encodeErrorToFailure(this.dataConverter, err);
195+
failure.stackTrace = undefined;
196+
return { cancelled: { failure } };
197+
}
182198
} else if (isAbortError(err)) {
183199
return { cancelled: { failure: { source: FAILURE_SOURCE, canceledFailureInfo: {} } } };
184200
}

0 commit comments

Comments
 (0)