title: Chrome Extension: "No resource with given identifier found" when trying to Network.getResponseBody
body: <p>I'm writing a Chrome Extension that can get HTTP response for a site. I try to use debugger for getting response body:</p>
  <pre class="lang-js prettyprint-override"><code>var gCurrentTab;
  
  chrome.debugger.onEvent.addListener(function (source, method, params) {
          if (gCurrentTab.id != source.tabId) {
              return;
          }
          if (method == &quot;Network.loadingFinished&quot;) {
              var tabId = source.tabId;
              var requestId = params.requestId;
              chrome.debugger.sendCommand(
                  source,
                  &quot;Network.getResponseBody&quot;,
                  {&quot;requestId&quot;: requestId},
                  function (body) {
                      console.log(body);
                      chrome.debugger.detach(source);
                  });
          }
      }
  );
  
  chrome.webRequest.onBeforeRequest.addListener(function (details) {
          var url = details.url;
          if (url.indexOf('/mypage') &gt;= 0) {
              chrome.tabs.query({
                  currentWindow: true,
                  active: true
              }, function (tabs) {
                  gCurrentTab = tabs[0];
                  chrome.debugger.attach({
                      tabId: gCurrentTab.id
                  }, &quot;1.0&quot;, function () {
                      chrome.debugger.sendCommand({
                          tabId: gCurrentTab.id
                      }, &quot;Network.enable&quot;);
                  });
              });
          }
      },
      {urls: []}, [&quot;requestBody&quot;, &quot;blocking&quot;]);
  </code></pre>
  <p>But I always get</p>
  <p>Unchecked runtime.lastError while running debugger.sendCommand: {&quot;code&quot;:-32000,&quot;message&quot;:&quot;No resource with given identifier found&quot;}
  at chrome-extension://ikphgobkghdkjkfplgokmapjlbdfeegl/background.js:11:29</p>
  <p>error, and the body is undefined.</p>
  <p>Does anyone have idea about why this happen? Thanks!</p>