Skip to content

fix(v7): Allow removal of message listeners on utility processes - #1474

Open
timfish wants to merge 1 commit into
v7from
fix/utility-process-listener-removal-v7
Open

timfish wants to merge 1 commit into
v7from
fix/utility-process-listener-removal-v7

Conversation

@timfish

@timfish timfish commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Backport of #1472 to v7. Fixes #1466 for the 7.x line.

configureUtilityProcessIPC() replaced child.on with a Proxy that registered an anonymous wrapper around each message listener to hide the SDK's handshake message. off and removeListener compare by identity and never found the wrapper, so listeners were never removed. once broke the same way because Node's once calls on, so its wrapper was wrapped again and never removed itself. addListener and prependListener were not wrapped and received the handshake message.

The wrapping now covers all five add methods and each wrapper carries a listener property pointing at the caller's function. Node's removeListener and listeners() look through that property, so off and listeners() work without proxying them. once registers a wrapper that removes itself on the first message that is not hidden.

Clean cherry-pick apart from one import conflict. Unit tests and the issue's script pass against the v7 build; the utility process e2e tests pass.

@timfish
timfish requested a review from JPeer264 October 15, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant