From 1515ca11a8be49e9a000afcc1c94e778faae57b5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sat, 12 May 2018 13:21:27 -0600 Subject: [PATCH] Add a warning for widget developers when their postMessage is missing a requestId Signed-off-by: Travis Ralston --- src/FromWidgetPostMessageApi.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/FromWidgetPostMessageApi.js b/src/FromWidgetPostMessageApi.js index 13ffb4a74b..792fd73733 100644 --- a/src/FromWidgetPostMessageApi.js +++ b/src/FromWidgetPostMessageApi.js @@ -116,6 +116,12 @@ export default class FromWidgetPostMessageApi { return; // don't log this - debugging APIs like to spam postMessage which floods the log otherwise } + // Although the requestId is required, we don't use it. We'll be nice and process the message + // if the property is missing, but with a warning for widget developers. + if (!event.data.requestId) { + console.warn("fromWidget action '" + event.data.action + "' does not have a requestId"); + } + const action = event.data.action; const widgetId = event.data.widgetId; if (action === 'content_loaded') {