-
Notifications
You must be signed in to change notification settings - Fork 753
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
[Bug]: Worker code hangs when message passing with sync-send
and receiver terminates with a non-error value
#42476
Comments
@HindujaB and I were discussing this. This scenario is not really handled in the implementation. When we have an error return, we propagate that error to the sender. public function main() {
worker w1 {
1 ->> w2;
error? unionResult = 2 ->> w2; // we enforce assignment here and get possible error assigned to a variable
}
worker w2 returns error? {
boolean b = true;
int _ = <- w1;
if b {
return error("error"); // error return
}
int _ = <- w1;
}
wait w1;
} Option 1: Option 2: Option 3: |
Adding to @lochana-chathura's comment, the current spec does not cover this scenario. But, it mentions like this.
And, through the And for receive action, if the corresponding worker channel is closed which indicates the send action will not complete (for conditional send actions), we return a Similarly, wouldn't it be more consistent to return an error in the above scenario as well? only for the |
I think the best thing to do here is option 3. (Additionally, we need to disallow This would make sure the following line from the spec is not violated.
Plus, we can always go for option 1 and 2 later on top of this after careful evaluation. |
Isn't this the same as a send stmt in an alternative receive? Where the send value is ignored. IIRC, that is what was discussed offline. |
I see your point. In these scenarios, though we have So if we consider overall communication which comprises a sending part and a receiving part, either the sender or receiver knows what happened in the communication. However, in the original code sample in this issue, none of the end knows what happened. [1] public function main() {
worker w1 {
boolean b = false;
if b {
() _ = 1 ->> function ;
}
() _ = 2 ->> function ;
}
int|error:NoMessage x = <- w1;
io:println(x); // error NoMessage
int y = <- w1;
io:println(y); // 2
} [2] public function main() {
worker w1 {
boolean b = false;
if b {
() _ = 1 ->> function ;
}
() _ = 2 ->> function ;
}
int|error:NoMessage x = <- w1|w1;
io:println(x); // 2
} |
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now. |
Description
Consider the below code. It hangs when we run it. However, this code works for the
asyc-send
The text was updated successfully, but these errors were encountered: