Removing patched function calls in workflow code

With reference to documentation here: TypeScript SDK developer's guide - Versioning | Temporal Documentation

If I have a workflow which has the following patch call:

if (patched('my-change-id')) {
    if(someBoolean) {
            await activityB();
            await sleep('1 days');
    }
  }

and now I want to add another patch call

if (patched('my-change-id-2')) {
            await activityB();
            await sleep('1 days');
}

basically removing the someBoolean check, is it safe to remove the first patch call completely? we realised a bit late that there was no need for the boolean check

additional info: the someBoolean value has always been false, so the code block within was actually never executed

we don’t want to deprecate the patch essentially at this point as there are a few other my-change-id patch calls elsewhere and workflows that have run through it

You’d have to keep both versions if you have workflow histories with the my-chane-id patch.

if (patched('my-change-id')) {
    if(someBoolean) {
            await activityB();
            await sleep('1 days');
    }
} else if (patched('my-change-id-2')) {
            await activityB();
            await sleep('1 days');
}
1 Like

Thanks for your reply

also - would it be safe to just remove

if(someBoolean) {
            await activityB();
            await sleep('1 days');
 }

from the first patch call since someBoolean was always false and no workflows with/without the patch executed the activity/sleep timer?

If you can ensure that someBoolean was always false, you could remove that branch from you’re code.

You’d be left with:

deprecatePatch('my-change-id');
if (patched('my-change-id-2')) {
  await activityB();
  await sleep('1 days');
}

It would be safe to remove the deprecated patch after there are no more histories that have the non deprecated patch in them.

1 Like