Excessive number of pending callbacks: 501. Some pending callbacks that might have leaked

Viewed 6956

In my react-native project, I am getting the following error message:

Warning: Please report: Excessive number of pending callbacks: 501. Some pending callbacks that might have leaked by never being called from native code:
{"203":{"module":"MyModule","method":"startProcessing"},"276":{"module":"RNFetchBlob","method":"emitExpiredEvent"},"1855":{},"1856":{},"1857":{},"1858":{},"1859":{},"1860":{},"1861":{},"1862":{},"1863":{},"1864":{},"1865":{},"1866":{},"1867":{},"1868":{},"1869":{},"1870":{},"1871":{},"1872":{},"1873":{},"1874":{},"1875":{},"1876":{},"1877":{},"1878":{},"1879":{},"1880":{},"1881":{},"1882":{},"1883":{},"1884":{},"1885":{},"1886":{},"1887":{},"1888":{},"1889":{},"1890":{},"1891":{},"1892":{},"1893":{},"1894":{},"1895":{},"1896":{},"1897":{},"1898":{},"1899":{},"1900":{},"1901":{},"1902":{},"...(truncated keys)...":451}

Can anyone tell me what module all of these callbacks are coming from or how to interpret this message?

4 Answers

This was a really hard one for me to track down.

What it came down to: This would only occur when I was running on a low spec device (Galaxy A12). I had a hook that looked like this:

  const [state, setState] = useState(1);
  useEffect(() => {
    const t = setInterval(
      () => setState(valueGoesHere),
      200,
    );
    return () => clearInterval(t);
  }, []);

To poll a value.

This worked fine on higher spec'd phones but it caused the excessive promise issue. You should comb your code for anything like the above snippet, especially using setInterval as it will bank up promises and not allow prior ones time to finish before dispatch.

It seems that the issue was that an async function was being executed in a loop. The loop was firing off lots of async calls almost simultaneously which resulted in excessive number of pending callbacks.

I had this issue with an async function inside a useEffect() while the my device was running debug mode (connected to a debugger). I resolved the issue by disconnecting the debugger.

It seems that the issue when I remove [] from useEffect

React.useEffect(() => { ...do somethings }, []);

and it work when I added it back

Related