From ac0e28a2b1a43d8efbd69ab7246dd5283c2ce24c Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 6 May 2021 08:21:08 -0700 Subject: [PATCH] Introduce some warnings if plugins send to much data Reviewed By: passy Differential Revision: D28253456 fbshipit-source-id: 00259076a86cf53ee80282c798c229460d7e4633 --- desktop/app/src/Client.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop/app/src/Client.tsx b/desktop/app/src/Client.tsx index 2ab16344b..cf1ce28c5 100644 --- a/desktop/app/src/Client.tsx +++ b/desktop/app/src/Client.tsx @@ -436,6 +436,13 @@ export default class Client extends EventEmitter { const params: Params = data.params; const bytes = msg.length * 2; // string lengths are measured in UTF-16 units (not characters), so 2 bytes per char emitBytesReceived(params.api, bytes); + if (bytes > 5 * 1024 * 1024 && params.api !== 'flipper-messages') { + console.warn( + `Plugin '${params.api}' received excessively large message for '${ + params.method + }': ${Math.round(bytes / 1024)}kB`, + ); + } const persistingPlugin: PluginDefinition | undefined = this.store.getState().plugins.clientPlugins.get(params.api) ||