Test failures: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
Environment
- Browser and full version: Chrome
- Extension using this toolkit: test-mv2 and test-mv3
- Commit hash: 10527d05
Issue
I've noticed sporadic test failures on Chrome with the error message
Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
Example log: https://gitlab.com/eyeo/adblockplus/abc/webext-sdk/-/jobs/2560767803
This seems to be related to this issue in webextension-polyfill
: https://github.com/mozilla/webextension-polyfill/issues/384
It seems that this in an error that Chrome throws when the background script is sent a message, and it responds to that message asynchronously, but by the time it responds the tab it was responding to has already been closed.
What to do
- If necessary, assist the upstream in getting the issue fixed so we can later upgrade our dependency to a version without this problem.
- Figure out why this is happening in tests and make the tests behave differently to avoid this issue.