feat(editor): Gracefully ignore invalid payloads in postMessage handler (#8096)

It's possible for browser extensions to send `message` events to an n8n window.
This change improves the already existing check to ignore invalid messages.

Fixes https://community.n8n.io/t/errors-in-the-browser-console-on-n8n-1-version/33910
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-12-19 15:20:29 +01:00 committed by GitHub
parent 36a923cf7b
commit 9d22c7a278
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4351,7 +4351,7 @@ export default defineComponent({
}
},
async onPostMessageReceived(message: MessageEvent) {
if (!message?.data?.includes?.('"command"')) {
if (!message || typeof message.data !== 'string' || !message.data?.includes?.('"command"')) {
return;
}
try {