Javascript error: Uncaught (in promise) Error after upgrading dash to 2.7.1

I am seeing a bunch of errors in the console after upgrading dash to 2.7.1

Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received


Uncaught (in promise) Error: There is already a source with this ID

at r.addSource (async-plotlyjs.js:2:1020888)
    at i.addSource (async-plotlyjs.js:2:1219363)
    at l.addSource (async-plotlyjs.js:2:2988732)
    at async-plotlyjs.js:2:2989736
    at h (async-plotlyjs.js:2:2989770)
    at l.update (async-plotlyjs.js:2:2990100)
    at b.updateData (async-plotlyjs.js:2:2338377)
    at async-plotlyjs.js:2:2336961

This error message indicates that there was a problem with the communication between the listener and the message channel. The reason is that sendMessage is now promisified internally, so you can ‘await’ it, but the by-product is that when you don’t specify a callback yourselves, it is added internally anyway in order for the call to return a Promise, which means that since you don’t call sendResponse in onMessage, the API will think that it was you who made a mistake of using a callback and not providing a response, and report it as such.

Since the new behaviour is very confusing for almost everyone, a solution might be to stop showing this error when the callback is not specified, however it might cause confusion for those developers who still use callbacks and forgot to call sendResponse inside onMessage by mistake, which should be reported ideally as it always was.

If you see your extension causing this errors - inspect closely all your onMessage listeners. Some of them probably need to start returning promises (marking them as async should be enough).

If still error showing, try disabled all installed extensions in Chrome then you will get a clear console without errors.

The error started occurring after I upgraded dash to latest version 2.7.1. Is there anything in the application code you’d suggest fixing? Perhaps, in the callbacks?