
When you send an async response but fail to use either of these mechanisms, the supplied sendResponse argument to sendMessage goes out of scope and the result is exactly as the error message says: your message port (the message-passing apparatus) is closed before the response was received. When you have the response (or reject it in case of an error).

return a Promise from the event listener, and resolve.This keeps the sendResponseįunction valid after the listener returns, so you can call it later. To send an asynchronous response, there are two options: The issue is most likely a mishandled async response to ndMessage. The issue isn't CORB (as another answer here states) as blocked CORs manifest as warnings like -Ĭross-Origin Read Blocking (CORB) blocked cross-origin response

In case you're an extension developer who googled your way here trying to stop causing this error:
