Callback was already called


I keep seeing this error in console:

Uncaught Error: Callback was already called.
  at vendor.js:19
  at vendor.js:19
  at C3Request.childDataSourceLoadFailed (VM34211 application.js:8)
  at Collection.<anonymous> (VM34211 application.js:8)
  at Collection.<anonymous> (vendor.js:33)
  at Collection.<anonymous> (vendor.js:1)
  at h (vendor.js:33)
  at Collection.trigger (vendor.js:33)
  at Collection.onLoadFailure (VM34211 application.js:3)
  at C3Request.handleResponse (VM34211 application.js:8)

I believe it’s caused by calling the callback in async more than once, possibly for retries!
This is preventing the childDataSource mapping from handling correctly the updates when a response if received.

How I can fix this issue?



The problem was that the listeners on data load are called by an async multiple times, to fix this I replaced the use of async with setTimeout that I make sure to clear before calling again.