xihaian251 commented on PR #1027:
URL: https://github.com/apache/burr/pull/1027#issuecomment-6634275726

   Thanks for the implementation. I independently exercised a 35-scenario 
matrix covering synchronous and asynchronous early termination. I agree that 
the core close-propagation mechanism is sound, and I recommend merging the PR.
   
   I found two additional edge cases worth documenting and addressing:
   
   **1. AnyIO cancellation can interrupt awaited resource cleanup 
(Medium–High).**
   
   I reproduced a case where an async streaming action owns a resource through 
`async with`, and its `__aexit__` performs an awaited release operation. When 
the consumer is cancelled through an AnyIO task-group cancel scope, the 
observed result is:
   
   ```text
   release_started  = True
   release_finished = False
   ```
   
   The same behavior reproduces with a bare async generator and no Burr code 
involved. Plain `asyncio.Task.cancel()` completes the release, so this is 
specifically related to AnyIO's level-cancellation semantics.
   
   This makes the new documentation statement that "the action is still cleaned 
up" too strong. The current cancellation test also does not exercise an awaited 
cleanup operation.
   
   I suggest clarifying that cleanup may be interrupted when it contains awaits 
under an active cancellation scope, and adding a regression test that captures 
this behavior.
   
   **2. Repeated close/aclose calls can expose inconsistent exceptions 
(Medium).**
   
   I reproduced the same issue in both synchronous and asynchronous containers.
   
   When both the action cleanup and `post_run_step` hook raise:
   
   - First close/aclose raises `HookError`.
   - Subsequent calls raise `CleanupError`.
   
   When only the hook raises:
   
   - First close/aclose raises `HookError`.
   - The second call returns `None`, although the step was never recorded.
   
   This appears to result from the callback exception replacing the cleanup 
exception in the first call, combined with `_callback_realized` being set 
before callback execution.
   
   The behavior is inconsistent with the `aclose()` docstring, which promises 
that cleanup exceptions are raised again on subsequent calls.
   
   I suggest defining an explicit exception-precedence contract and adding 
tests for both failure combinations.
   
   Neither finding invalidates the main early-close implementation. I am 
sharing these as collaborative follow-up findings rather than requesting 
changes to the core mechanism.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to