File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
packages/electron-chrome-extensions/src/browser/api/lib Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ async function readNativeMessagingHostConfig(
9999}
100100export class NativeMessagingHost {
101101 private process ?: ReturnType < typeof spawn >
102- private sender : ExtensionSender
102+ private sender ? : ExtensionSender
103103 private connectionId : string
104104 private connected : boolean = false
105105 private pending ?: any [ ]
@@ -130,10 +130,11 @@ export class NativeMessagingHost {
130130 this . process . kill ( )
131131 this . process = undefined
132132 }
133- if ( this . keepAlive ) {
133+ if ( this . keepAlive && this . sender ) {
134134 this . sender . ipc . off ( `crx-native-msg-${ this . connectionId } ` , this . receiveExtensionMessage )
135135 this . sender . send ( `crx-native-msg-${ this . connectionId } -disconnect` )
136136 }
137+ this . sender = undefined
137138 }
138139
139140 private async launch ( application : string , extensionId : string ) {
@@ -216,7 +217,7 @@ export class NativeMessagingHost {
216217 const length = data . readUInt32LE ( 0 )
217218 const message = JSON . parse ( data . subarray ( 4 , 4 + length ) . toString ( ) )
218219 d ( 'receive: %s' , message )
219- if ( this . keepAlive ) {
220+ if ( this . keepAlive && this . sender ) {
220221 this . sender . send ( `crx-native-msg-${ this . connectionId } ` , message )
221222 } else {
222223 this . resolveResponse ?.( message )
You can’t perform that action at this time.
0 commit comments