Should I call sendResponse?


I am using chrome.extension.onRequest.addListener

, I can see that I am calling sendResponse with no arguments ( => sendResponse();

). Sometimes I get the error:
Error: Attempting to use a disconnected port object

Should I call sendResponse, or can I remove this function if I don't expect to receive a response from the background?

+3


source to share


1 answer


The documentation says:

A function to call (at most once) when you have an answer.



This "at most once" type indicates that sending a response is optional. While I won't be able to get official confirmation, I've checked the source code of my extension and there are a few posts that do sendResponse

n't get called - so far (after a year of heavy use) no problems.

+1


source







All Articles