test(e2e): event handler can re-enter the library with a new request#67
Draft
Ivansete-status wants to merge 1 commit into
Draft
test(e2e): event handler can re-enter the library with a new request#67Ivansete-status wants to merge 1 commit into
Ivansete-status wants to merge 1 commit into
Conversation
Adds a C++ e2e case proving re-entrancy: from inside an `on_echo_fired` handler the consumer issues another request to the library, carrying data taken from the event, and gets a correct response back. The handler runs on the FFI thread with the event-registry lock held, so the test documents and exercises the only safe shape: an *async* request. A synchronous call from the handler would self-deadlock (the FFI thread is busy running the handler), and add/removeEventListener would deadlock on the registry lock. The async request merely queues on the FFI channel and is drained once the handler returns; its future is moved out and resolved on the main thread. A one-shot guard avoids the echo->event->echo storm (echo re-fires the event). Timeouts turn any deadlock regression into a failure rather than a hang. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a C++ end-to-end test for re-entrancy: from inside an
on_echo_firedevent handler, the consumer issues another request to the library (carrying information taken from the event) and receives a correct response — no deadlock, no UAF.Why this shape
The event handler runs on the FFI thread with the event-registry lock held (
dispatchFFIEventinffi_events.nim). The test pins down the safe contract:add/removeEventListenerfrom the handler would deadlock on the registry lock.A one-shot guard avoids the
echo → on_echo_fired → echostorm (echo re-fires the event). Thewait_fortimeouts turn any future deadlock regression into a test failure instead of a hang.Test
Full C++ e2e suite 20/20 (the new
EventHandlerCanIssueAsyncRequestplus the existing 19).🤖 Generated with Claude Code