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 #6577

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

patched always true inside Signal #6577

ianmateusES opened this issue Sep 30, 2024 · 0 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant