actor: add ErrMessageDropped for Ask path when mailbox drops#10652
actor: add ErrMessageDropped for Ask path when mailbox drops#10652erickcestari wants to merge 1 commit intolightningnetwork:masterfrom
Conversation
When the BackpressureMailbox's RED policy drops a message, Send returns false but neither context is cancelled. The Ask path previously completed the promise with fn.Err[R](ctx.Err()) where ctx.Err() is nil, producing a confusing nil-wrapped error. Add a three-way check that returns ErrMessageDropped in this case.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the error handling within the actor system's Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug in the Ask pattern where a message dropped by a mailbox's policy would result in a confusing nil-wrapped error. By introducing ErrMessageDropped and adding a three-way check, the new logic properly handles this scenario. My only suggestion is to add unit test coverage for this new error path to ensure its robustness, which might require a minor refactoring to allow injecting a mock mailbox for testing.
| } else { | ||
| // Neither context cancelled — the mailbox's drop | ||
| // policy (e.g., RED) rejected the message. | ||
| promise.Complete(fn.Err[R](ErrMessageDropped)) | ||
| } |
There was a problem hiding this comment.
This change introduces a new error path for when a message is dropped by the mailbox policy. However, there are no tests to cover this new logic. With the current ChannelMailbox, this path is unreachable.
To ensure the correctness of this logic, especially with the future introduction of BackpressureMailbox, I recommend adding a unit test. This might require a small refactoring to allow injecting a mock Mailbox during actor creation for testing purposes. For example, the ActorConfig could be extended to optionally take a Mailbox instance, which would make the actor system more flexible and easier to test.
When the
BackpressureMailbox's RED policy drops a message, Send returns false but neither context is cancelled. TheAskpath previously completed the promise withfn.Err[R](ctx.Err())wherectx.Err()is nil, producing a confusing nil-wrapped error. Add a three-way check that returnsErrMessageDroppedin this case.BackpressureMailboxwill be added on: #10219