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

When Ask<> called with timeout == TimeSpan zero, timeout is never risen nor argument exception is thrown #6131

Closed
procode-rd opened this issue Oct 4, 2022 · 3 comments · Fixed by akkadotnet/akka.analyzers#17
Assignees
Labels
akka-actor rosyln-analyzer Issues that should be addressed via user-exposed Roslyn analyzers. won't fix

Comments

@procode-rd
Copy link

Version Information
Akka.NET 1.4.38
Which Akka.NET Modules? Akka

Describe the bug
In call to Ask extension method, passing timeout with value TimeSpan.Zero causes method to block indefinitely without throwing AskTimeoutException

To Reproduce

TimeSpan timeout = default;
IActorRef someActorRef = ...

someActorRef.Ask("SomeMessageWhatHasNoHandler", timeout);
// here execution thread will be blocked indefinitely. no exception (neither AskTimeoutException nor ArgumentException).

Expected behavior
Ask extension method will thrown ArgumentException with message disallowing to use zero.
OR
AskTimeoutException will be thrown immediately without allocating other objects in method.

I'd prefer first expectation as calling Ask with zero timeout contradicts any need to call of that method.
Usually this comes from code error (as in my case) from code dynamically fetching or calculating timeout.

Actual behavior
Thread is blocked indefinitely.

Screenshots
image

Environment
.NET Framework 4.8. Windows 10 64bit.

@Aaronontheweb
Copy link
Member

Aaronontheweb commented Oct 4, 2022

We do allow Timespan.Infinite today by default, but we probably shouldn't allow Timespan.Zero. Ok, I think that should be easy to fix against the v1.4 branch.

@Aaronontheweb Aaronontheweb added this to the 1.4.44 milestone Oct 4, 2022
@Arkatufus Arkatufus removed this from the 1.4.44 milestone Oct 6, 2022
@Arkatufus
Copy link
Contributor

Fixing this is much more complicated than we thought, we'll try and a Roslyn Analyzer to catch this in the future.

@Aaronontheweb Aaronontheweb reopened this Oct 6, 2022
@Aaronontheweb Aaronontheweb closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2022
@Aaronontheweb
Copy link
Member

Changing the internals of Ask<T> to catch this had a lot of side effects even in our own test suite - so we think it's probably best to put a layer of Roslyn analysis on top as a solution instead, like @Arkatufus suggested.

@Aaronontheweb Aaronontheweb reopened this Oct 6, 2022
@Aaronontheweb Aaronontheweb added the rosyln-analyzer Issues that should be addressed via user-exposed Roslyn analyzers. label Oct 6, 2022
Aaronontheweb added a commit to akkadotnet/akka.analyzers that referenced this issue Dec 29, 2023
Aaronontheweb added a commit to akkadotnet/akka.analyzers that referenced this issue Dec 29, 2023
* Check for `TimeSpan.Zero` on `Ask` and `Ask<T>` operationrs

close #11
close akkadotnet/akka.net#6131

* working on specs

* sdfsdf

* have tests finally starting to pass

* cleaning up tests and unused code

* disabled variable scanning - not supported yet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
akka-actor rosyln-analyzer Issues that should be addressed via user-exposed Roslyn analyzers. won't fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants