Skip to content

Commit

Permalink
Use warnOnce for excessive number of callbacks error (#26508)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Sep 23, 2019
1 parent 30e9443 commit 0cafa0f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Libraries/BatchedBridge/MessageQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)}`,
);
}
}
Expand Down

0 comments on commit 0cafa0f

Please sign in to comment.