From 5cf3d96ae30b2f485167b8989b8136317cf23e2b Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 23 Sep 2019 10:12:45 -0700 Subject: [PATCH] Use `warnOnce` for excessive number of callbacks error (#26508) Summary: I happened to hit this error a couple times and the issue is that if there are let's say 1000 pending callbacks the error would be triggered 500 times and pretty much crash the app. I think it is reasonable to use warn once here so it only happens once. ## Changelog [General] [Fixed] - Use `warnOnce` for excessive number of callbacks error Pull Request resolved: https://github.com/facebook/react-native/pull/26508 Test Plan: Tested by reducing the number of pending callbacks required to trigger the error. Reviewed By: TheSavior Differential Revision: D17512917 Pulled By: JoshuaGross fbshipit-source-id: 5ce8e2a0a166805cc6f3fe6d78e2716d6792a80e --- Libraries/BatchedBridge/MessageQueue.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 260a38f297dd15..93ac7436c1953f 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -16,6 +16,7 @@ const Systrace = require('../Performance/Systrace'); const deepFreezeAndThrowOnMutationInDev = require('../Utilities/deepFreezeAndThrowOnMutationInDev'); const invariant = require('invariant'); const stringifySafe = require('../Utilities/stringifySafe'); +const warnOnce = require('../Utilities/warnOnce'); export type SpyData = { type: number, @@ -225,11 +226,13 @@ class MessageQueue { const method = debug && this._remoteMethodTable[debug[0]][debug[1]]; info[callID] = {module, method}; }); - console.error( + warnOnce( + 'excessive-number-of-pending-callbacks', `Please report: Excessive number of pending callbacks: ${ this._successCallbacks.size - }. Some pending callbacks that might have leaked by never being called from native code:`, - info, + }. Some pending callbacks that might have leaked by never being called from native code: ${stringifySafe( + info, + )}`, ); } }