Skip to content

Commit 0cafa0f

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
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: #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
1 parent 30e9443 commit 0cafa0f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Libraries/BatchedBridge/MessageQueue.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const Systrace = require('../Performance/Systrace');
1616
const deepFreezeAndThrowOnMutationInDev = require('../Utilities/deepFreezeAndThrowOnMutationInDev');
1717
const invariant = require('invariant');
1818
const stringifySafe = require('../Utilities/stringifySafe');
19+
const warnOnce = require('../Utilities/warnOnce');
1920

2021
export type SpyData = {
2122
type: number,
@@ -225,11 +226,13 @@ class MessageQueue {
225226
const method = debug && this._remoteMethodTable[debug[0]][debug[1]];
226227
info[callID] = {module, method};
227228
});
228-
console.error(
229+
warnOnce(
230+
'excessive-number-of-pending-callbacks',
229231
`Please report: Excessive number of pending callbacks: ${
230232
this._successCallbacks.size
231-
}. Some pending callbacks that might have leaked by never being called from native code:`,
232-
info,
233+
}. Some pending callbacks that might have leaked by never being called from native code: ${stringifySafe(
234+
info,
235+
)}`,
233236
);
234237
}
235238
}

0 commit comments

Comments
 (0)