@@ -143,7 +143,11 @@ export class Activity {
143
143
( error instanceof CancelledFailure || isAbortError ( error ) ) &&
144
144
this . context . cancellationSignal . aborted
145
145
) {
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
+ }
147
151
} else if ( error instanceof CompleteAsyncError ) {
148
152
this . workerLogger . debug ( 'Activity will complete asynchronously' , { durationMs } ) ;
149
153
} else {
@@ -176,9 +180,21 @@ export class Activity {
176
180
} else if ( this . cancelReason ) {
177
181
// Either a CancelledFailure that we threw or AbortError from AbortController
178
182
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
+ }
182
198
} else if ( isAbortError ( err ) ) {
183
199
return { cancelled : { failure : { source : FAILURE_SOURCE , canceledFailureInfo : { } } } } ;
184
200
}
0 commit comments