Skip to content
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

patched always true inside Signal #1555

Open
ianmateusES opened this issue Sep 30, 2024 · 2 comments
Open

patched always true inside Signal #1555

ianmateusES opened this issue Sep 30, 2024 · 2 comments

Comments

@ianmateusES
Copy link

Required

What is the issue?

How can we reproduce the issue?

Create a long-running workflow with a signal and start it. Then, make some changes to that signal and use patched to point to the new version.

What is the expected behavior?

Example

Additional context (optional—the more we know, the faster it goes)

Screenshots:
N/A

Browser and version:
N/A

Device and screen size:
N/A

Expected Behavior

Existing workflows are expected to use the previous signal flow, while new ones are redirected by patched. However, what happens is that they all end up going to the new flow, since patched always returns true.

Actual Behavior

How patched works inside the setHandler of a Signal. For every patchId set, wf.patched(patchId) returns true

Steps to Reproduce the Problem

  • Workflow v1:
import { sleep, defineSignal, defineQuery, setHandler, log, patched } from '@temporalio/workflow';

export const updateMessage = defineSignal<[string]>('updateMessage');
export const query = defineQuery('query');

export async function longRunningWorkflow(): Promise<void> {
  let message = 'Initial message';

  setHandler(updateMessage, (newMessage: string) => {
    message = newMessage;
  });

  setHandler(query, () => message);

  await sleep(10 * 60 * 1000);
}
  • Workflow v2:
import { sleep, defineSignal, defineQuery, setHandler, log, patched } from '@temporalio/workflow';

export const updateMessage = defineSignal<[string]>('updateMessage');
export const query = defineQuery('query');

export async function longRunningWorkflow(): Promise<void> {
  let message = 'Initial message';

  setHandler(updateMessage, (newMessage: string) => {
    if (patched('v2')) {
      log.info('Workflow was patched');
      message = newMessage + ' v2';
    } else {
      message = newMessage;
    }
  });

  setHandler(query, () => message);

  await sleep(10 * 60 * 1000);
}

Specifications

  • Version: 1.8.0
  • Platform: Docker v27.3.1
@bergundy bergundy transferred this issue from temporalio/temporal Oct 31, 2024
@mjameswh
Copy link
Contributor

mjameswh commented Nov 6, 2024

I can't reproduce an incorrect behavior with the code you provided.

Your report indicates you are using TS SDK 1.8.0. I think you are most likely hitting a bug that was fixed in 1.8.5 (see #1234).

Can you please try this with TS SDK v1.11.3? Or if you want to remain on 1.8.x, please update to 1.8.6.

@josh-berry
Copy link

Hi @ianmateusES, did upgrading the SDK resolve this for you?

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

No branches or pull requests

3 participants