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

DotNext.Metaprogramming. Regression: worked in v 2.12.2, hangs in higher versions. #70

Closed
ycherkes opened this issue Jun 4, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ycherkes
Copy link

ycherkes commented Jun 4, 2021

public class Test
{
    [Fact]
    public async Task AsyncLambdaDoesntHangInTryBlock()
    {
        Expression<Func<Task<string>>> exprThrowException = () => ThrowException();
        Expression<Func<Task<string>>> exprReprocess = () => Reprocess();

        var asyncTryCatchExpression = AsyncLambda<Func<Task<string>>>(
            (lambdaContext, result) =>
            {
                Try(() =>
                    {

                        Assign(result, Expression.Invoke(exprThrowException).Await());
                        Return(result);
                    })
                    .Catch<Exception>(() =>
                    {
                        Assign(result, Expression.Invoke(exprReprocess).Await());
                        Return(result);
                    })
                    .End();
            });

        var asyncTryCatchFunc = asyncTryCatchExpression.Compile();
        var asyncTryCatchTask = asyncTryCatchFunc();

        var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
        await await Task.WhenAny(asyncTryCatchTask, Task.Delay(-1, cancellationTokenSource.Token));
    }


    private static async Task<string> ThrowException()
    {
        await Task.Delay(TimeSpan.FromSeconds(1));
        throw new Exception();
    }

    private static Task<string> Reprocess()
    {
        return Task.FromResult(string.Empty);
    }
}
@ycherkes ycherkes changed the title DotNext.Metaprogramming Regression: worked in v 2.12.2, hangs in higher versions. DotNext.Metaprogramming. Regression: worked in v 2.12.2, hangs in higher versions. Jun 4, 2021
@sakno sakno self-assigned this Jun 4, 2021
@sakno sakno added the bug Something isn't working label Jun 4, 2021
@sakno
Copy link
Collaborator

sakno commented Jun 4, 2021

@ycherkes , patch has been added to develop branch

@ycherkes
Copy link
Author

ycherkes commented Jun 4, 2021

@ycherkes , patch has been added to develop branch

Thank you. I can check it on my project code on Monday.

@ycherkes
Copy link
Author

ycherkes commented Jun 7, 2021

Hi @sakno,
I've just checked the dev version in my project.
Hangs are gone.
When do you plan to release it?

@sakno
Copy link
Collaborator

sakno commented Jun 7, 2021

I hope this evening.

@sakno sakno closed this as completed in 90090e2 Jun 7, 2021
@ycherkes
Copy link
Author

ycherkes commented Jun 8, 2021

I hope this evening.

I saw that version 3.2.0 was released. Thank you.

@sakno sakno added this to Closed in Metaprogramming Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Metaprogramming
  
Closed
Development

No branches or pull requests

2 participants