Skip to content

Activity pause/unpause #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Activity pause/unpause #1729

wants to merge 11 commits into from

Conversation

THardy98
Copy link
Contributor

What was changed

Added support to pause/unpause an activity. Cancellations due to pause are received through the heartbeat mechanism of the activity.

Why?

Part of activity operator work.

  1. Closes Heartbeating activities should be interrupted when the activities are paused. #1665

  2. How was this tested:
    Couple integration tests

  3. Any docs updates needed?
    Likely

@THardy98 THardy98 requested a review from a team as a code owner June 19, 2025 11:47
@THardy98 THardy98 changed the title Activity pause unpause Activity pause/unpause Jun 19, 2025
@THardy98 THardy98 mentioned this pull request Jun 19, 2025
@@ -30,7 +30,7 @@ export interface MockActivityEnvironmentOptions {
* will immediately be in a cancelled state.
*/
export class MockActivityEnvironment extends events.EventEmitter {
public cancel: (reason?: any) => void = () => undefined;
public cancel: (reason?: any, details?: any) => void = () => undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would a MockActivityEnvironment user be expected to provide as input for the details argument? The signature says any, and the ActivityCancellationDetails class has a private constructor, so it looks like it is simply impossible for users to provide anything useful here.

One solution would be to have ActivityCancellationDetails be just an interface, rather than a class, but then we'd have to make all properties optional, as adding more fields in the future would be a backward incompatible change.

Can you please look at what we do with this in other SDKs, and try to figure out a proper API for this?

And btw, reason being any also feels wrong.

/**
* Holder object for activity cancellation details
*/
public readonly cancellationDetails: ActivityCancellationDetailsHolder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you introduced this holder. I'm not convinced this is the best solution. An alternative would have been to split Context into an interface AND an implementation class. We'd obviously need to keep to export a Context object, to keep the current() static method, but that wouldn't be hard to do. But whatever, there's nothing wrong with the holder approach.

My real concern is that we're making that indirection be part of the public Context API. That's not desirable from an API perspective, and totally avoidable by keeping that field private, and exposing a cancellationDetails property getter instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made this private and provided a getter.
I'm in favour of this simple change to begin with, if the introduction of shared reference mutable fields grows, we can opt to split Context into interface + class impl.

@mjameswh
Copy link
Contributor

I haven't compared with what we did in other SDKs, but it looks like there was quite a few discussions while you were working on the corresponding Python PR.

Are you sure this PR correctly mirrors the final state of your Python one?

@THardy98
Copy link
Contributor Author

I haven't compared with what we did in other SDKs, but it looks like there was quite a few discussions while you were working on the corresponding Python PR.

Are you sure this PR correctly mirrors the final state of your Python one?

Yes, this mirrors the Python activity pause change

THardy98 added 5 commits July 23, 2025 14:46
…on details field in activity context private, make activity cancellation tests less flaky
@THardy98 THardy98 requested a review from mjameswh July 23, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Heartbeating activities should be interrupted when the activities are paused.
2 participants