Skip to content

Conversation

THardy98
Copy link
Contributor

@THardy98 THardy98 commented Aug 8, 2025

What was changed

The main change to accommodate eager workflow start was adding startWithDetails to WorkflowClientInterceptor to support a (new) return type of WorkflowStartOutput. This allows us to return an object, giving us the ability to add new fields without issue - we add eagerlyStarted in this PR. This new interceptor method is injected if not defined at the internal _start call, and adapts the existing start interceptor method to use startWithDetails. We also define a new handle called WorkflowHandleWithStartDetails which extends the existing WorkflowHandleWithFirstExecutionRunId, which now includes whether the workflow was started eagerly or not. Adding fields to the handle is an adopted pattern in the TS SDK.

Why?

Support eager workflow start.

  1. Closes [Feature Request] Eager Workflow Start #1348

  2. How was this tested:
    Existing integration tests and 2 new integration tests.

  3. Any docs updates needed?
    Probably

@THardy98 THardy98 requested a review from a team as a code owner August 8, 2025 21:13
@THardy98 THardy98 force-pushed the eager_workflow_start branch from 24a1314 to 9d137ac Compare August 11, 2025 23:17

const start = composeInterceptors(interceptors, 'start', this._startWorkflowHandler.bind(this));
// Adapt legacy `start` interceptors to the new `startWithDetails` interface.
const adaptedInterceptors: WorkflowClientInterceptor[] = interceptors.map((i) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nits:

  • Should probably move these adaptors to a distinct file. The workflow-client.ts file is already quite heavy.
  • I think we should adapt interceptors on Client creation, so that we don't have to do this repeatedly here.

Copy link
Contributor Author

@THardy98 THardy98 Sep 2, 2025

Choose a reason for hiding this comment

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

moved to interceptor-adapters.ts

I tried moving the adapt interceptors logic to client creation, but it causes an otel interceptor test to fail (Otel interceptor spans are connected and complete). I spent probably too much time trying to debug this (I believe it has to do with losing this context when we try to transform the interceptor), but wasn't able to solve it without resorting back to does this transformation directly in _start

Copy link
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

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

Just had a very quick look. Deferring to @Sushisource for more complete check.

Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Looking good to me. Just minor stuff about comments.

// Apply adapters to workflow client interceptor.
export function adaptWorkflowClientInterceptor(i: WorkflowClientInterceptor): WorkflowClientInterceptor {
Copy link
Member

Choose a reason for hiding this comment

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

Comment mostly just repeats function name. The comment for the "real" function seems sufficient.

Comment on lines 135 to 136
* Successor to {@link start}. Unlike {@link start}, this method returns
* start details via {@link WorkflowStartOutput}.
Copy link
Member

Choose a reason for hiding this comment

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

This comment will need to change when the deprecated start is removed. I'd get rid of the reference to the old thing and just talk about what it does.

const interceptors = Array.isArray(this.options.interceptors)
? (this.options.interceptors as WorkflowClientInterceptor[])
: [];
// Apply adapters to workflow client interceptors.
Copy link
Member

Choose a reason for hiding this comment

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

Obvious comment

Comment on lines 59 to 60
* Potentially reduce the latency to start this workflow by encouraging the server to
* start it on a local worker running with this same client.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Potentially reduce the latency to start this workflow by encouraging the server to
* start it on a local worker running with this same client.
* Potentially reduce the latency to start this workflow by requesting that the server
* start it on a local worker running with this same client.

- add startWithDetails to WorkflowClientInterceptor to support return type of WorkflowStartOutput, inject if not defined at _start call
- symbol usage to mark if connection supports ews
- separate file for interceptor adapters, adapt wf client interceptors on wf client creation
- deprecate `start` wf client interceptor in favor of `startWithDetails`
@THardy98 THardy98 force-pushed the eager_workflow_start branch from 9638f7f to 33d672c Compare September 2, 2025 21:37
@THardy98 THardy98 merged commit 49df572 into main Sep 3, 2025
42 of 43 checks passed
@THardy98 THardy98 deleted the eager_workflow_start branch September 3, 2025 00:21
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.

[Feature Request] Eager Workflow Start
3 participants