Skip to content

Conversation

aavshr
Copy link
Contributor

@aavshr aavshr commented Jun 26, 2025

Changes

Currently the connected guard is still false when destroy is called even if the extension native messaging config/host could not be found. The native port is never closed on these errors and hence also the onDisconnect event is never emitted for potential listeners. This PR gets rid of the connected guard check and also fixes a typo on the disconnect ipc channel name.


✅ By sending this pull request, I agree to the Contributor License Agreement of this project.

@aavshr aavshr changed the title fix (electron-chrome-extensions): always emit native port onDisconnect event when native messaging host is destroyed fix (electron-chrome-extensions): always disconnect native port when native messaging host is destroyed Jun 26, 2025
}

destroy() {
if (!this.connected) return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If destroy() is called twice, this will still attempt to send an IPC to this.sender. I'll fix this up after merging.

}
ipcRenderer.on(`crx-native-msg-${connectionId}`, onMessage)
ipcRenderer.once(`crx-native-msg-${connectNative}-disconnect`, () => {
ipcRenderer.once(`crx-native-msg-${connectionId}-disconnect`, () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, good catch!

@samuelmaddock samuelmaddock merged commit 9b52002 into samuelmaddock:master Jul 1, 2025
3 of 4 checks passed
@aavshr aavshr deleted the native-messaging-disconnect-fix branch July 2, 2025 07:48
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.

2 participants