Skip to content

Re-introduce default cancellationToken for PurgeInstanceAsync for backwards compatibility#276

Closed
davidmrdavid wants to merge 1 commit intomainfrom
dajusto/patch-purgeAsync
Closed

Re-introduce default cancellationToken for PurgeInstanceAsync for backwards compatibility#276
davidmrdavid wants to merge 1 commit intomainfrom
dajusto/patch-purgeAsync

Conversation

@davidmrdavid
Copy link
Copy Markdown
Member

@davidmrdavid davidmrdavid commented Mar 25, 2024

Follow-up to: #262

It would appear that in the refactoring above we accidentally made a breaking change to our PurgeInstancesAsync API, dropping the declaration of a PurgeInstanceAsync(string instanceId, CancellationToken cancellation = default) method, which is overriden here.

At a glance, I suspect this is the reason for our smoke test failures in the worker.extensions.durabletask package: https://github.com/Azure/azure-functions-durable-extension/actions/runs/8428205010/job/23080260061?pr=2772

Failure trace:

#10 7.776 /root/src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs(54,39): error CS0115: 'FunctionsDurableTaskClient.PurgeInstanceAsync(string, CancellationToken)': no suitable method found to override [/root/src/Worker.Extensions.DurableTask/Worker.Extensions.DurableTask.csproj]

This PR is a naive attempt at trying to fix them.


/// <inheritdoc cref="PurgeInstanceAsync(string, PurgeInstanceOptions, CancellationToken)"/>
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation = default)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From a binary compatibility perspective, this is still a breaking change. We need to introduce a virtual method that doesn't include the CancellationToken parameter at all.

public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
    => this.PurgeInstanceAsync(instanceId, CancellationToken.None);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait, maybe my suggestion isn't the right one. I'd need to double check where the failure is coming from.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll be honest, I haven't had the chance to validate my diff yet either. Just FYI

@davidmrdavid
Copy link
Copy Markdown
Member Author

Before I forget - let's validate that there weren't other similar breaking changes (in other client methods) that the test didn't catch but still need resolving.


/// <inheritdoc cref="PurgeInstanceAsync(string, PurgeInstanceOptions, CancellationToken)"/>
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation = default)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adding the default param back will cause ambiguous overload resolution with

public virtual Task<PurgeResult> PurgeInstanceAsync(
        string instanceId, PurgeInstanceOptions? options = null, CancellationToken cancellation = default)

when calling .PurgeInstanceAsync(string) (which of the 2 default param methods is it to use?)

We will also need to remove the default param from options in that other method.


/// <inheritdoc cref="PurgeInstanceAsync(string, PurgeInstanceOptions, CancellationToken)"/>
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation)
public virtual Task<PurgeResult> PurgeInstancesAsync(string instanceId, CancellationToken cancellation = default)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh! the error message you see of no overload resolution is because of the typo in #267

@davidmrdavid
Copy link
Copy Markdown
Member Author

Closing this as the expected bug fix was merged.

@davidmrdavid davidmrdavid deleted the dajusto/patch-purgeAsync branch March 26, 2024 22:59
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.

3 participants