title: Chrome Extension: runtime.lastError while running tabs.get/tabs.remove: No tab with id:0
body: <p>I've tried to find a solution, but the only thing I found was if a random TabId doesn't exist. But this doesn't solve my problem:</p>
  
  <p>I'm always getting these errors: <br></p>
  
  <blockquote>
    <p>Unchecked runtime.lastError while running tabs.get: No tab with id:0 <br>
    Unchecked runtime.lastError while running tabs.remove: No tab with id:0</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre><code>var tabnumber = 0; //the number of tabs in the current window
  var tabID = 0; //id of the active tab
  
  function closeBundle(){
    getTabnumber();
    for(i=0;i&lt;tabnumber;i++){
      getTabID();
      chrome.tabs.get(tabID , function(tab){ //here is the first problem
        insert[i] = tab; //for saving all Tabs in an array
      });
      chrome.tabs.remove(tabID); //here the second one
    }
  
    chache[active] = insert; //I save the insert array in another array
  }
  
  function getTabnumber(){
    chrome.tabs.query({'currentWindow': true}, function(tabarray){
      tabnumber = tabarray.length;
    });
  }
  
  function getTabID(){
    chrome.tabs.query({'currentWindow': true, 'active': true}, function(tabArray){
      tabID = tabArray[0].id;
    });
  }
  </code></pre>
  
  <p>I don't get it why there is no Tab with this specific id because I used the TabId of the active Tab (with getTabId), doesn't I??</p>
  
  <p>How can I get the right Id of the current Tab or is there another way to store all Tabs of the current window in an array and then close all tabs?</p>
  
  <p>I hope somebody could help me ;)</p>