title: How to implement "return true;"? Error: "The message port closed before a response was received."
body: <p>How can I implement that my event-handler returns <strong>true</strong>? (Tried everything but the error returns)</p>
  
  <p>I'm getting following error:</p>
  
  <blockquote>
    <p>"Unchecked runtime.lastError: The message port closed before a
    response was received."</p>
  </blockquote>
  
  <p>Solution is:</p>
  
  <blockquote>
    <p>"Note: The sendResponse callback is only valid if used synchronously,
    or if the event handler returns true to indicate that it will respond
    asynchronously. The sendMessage function's callback will be invoked
    automatically if no handlers return true or if the sendResponse
    callback is garbage-collected."</p>
  </blockquote>
  
  <p><a href="https://developer.chrome.com/extensions/messaging#simple" rel="noreferrer">https://developer.chrome.com/extensions/messaging#simple</a></p>
  
  <p>edit: See also (chrome): <a href="https://github.com/mozilla/webextension-polyfill/issues/130" rel="noreferrer">https://github.com/mozilla/webextension-polyfill/issues/130</a></p>
  
  <p>Here's my code, I would be very thankful:</p>
  
  <pre><code>// receive message from pop-up or options
  chrome.extension.onMessage.addListener(function (aRequest, aSender, 
  aSendResponse) {
      if (!aSender) {
          return;
      }
      switch (aRequest.cmd) {
          // reload lists
      case 'reload':
          XX.blockedDomains = {};
          XX.load();
          break;
          // send list of recently blocked
      case 'blocked':
          aSendResponse(Object.keys(XX.blockedDomains));
          break;
          // deny domain
      case 'deny':
          XX.blocklist[aRequest.domain] = 1;
          delete XX.blockedDomains[aRequest.domain];
          XX.save();
          break;
      }
  });
  </code></pre>