fix: serialize messages being sent over chrome message ports (#19104)
Chrome appears to serialize these messages (see #19070) so we should as well to be consistent and to avoid bugs with Uint8/16 arrays Fixes #19070
This commit is contained in:
parent
d0ece2bc93
commit
6d5e494782
1 changed files with 4 additions and 4 deletions
|
@ -40,10 +40,10 @@ class Port {
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRendererInternal.on(`CHROME_PORT_POSTMESSAGE_${portId}`, (
|
ipcRendererInternal.on(`CHROME_PORT_POSTMESSAGE_${portId}`, (
|
||||||
_event: Electron.Event, message: string
|
_event: Electron.Event, message: any
|
||||||
) => {
|
) => {
|
||||||
const sendResponse = function () { console.error('sendResponse is not implemented') }
|
const sendResponse = function () { console.error('sendResponse is not implemented') }
|
||||||
this.onMessage.emit(message, this.sender, sendResponse)
|
this.onMessage.emit(JSON.parse(message), this.sender, sendResponse)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ class Port {
|
||||||
this._onDisconnect()
|
this._onDisconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
postMessage (message: string) {
|
postMessage (message: any) {
|
||||||
ipcRendererInternal.sendToAll(this.tabId, `CHROME_PORT_POSTMESSAGE_${this.portId}`, message)
|
ipcRendererInternal.sendToAll(this.tabId, `CHROME_PORT_POSTMESSAGE_${this.portId}`, JSON.stringify(message))
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDisconnect () {
|
_onDisconnect () {
|
||||||
|
|
Loading…
Reference in a new issue