After the recent Chrome update my extension started to fire "Unchecked runtime.lastError: Tabs cannot be edited right now (user may be dragging a tab)" when I attempt to use chrome.tabs API. There is not much info on this issue yet, but I believe this is a browser bug. In the meantime my extension causes the chrome tabs to switch noticeably slower, that it used to be. It now takes a couple of seconds to change the tab. So I'm looking for a workaround.
Any ideas how to fix this?
The only solution that I have found so far is to put my handlers in a timeout like this:
chrome.tabs.onActivated.addListener((activeInfo) => {
setTimeout(() => {
// The old listener handler moves here
}, 100);
});
But there must be a better way, right?
You will still get errors but at least it will work
chrome.tabs.onActivated.addListener(function(activeInfo) {getActivatedTab();});
function getActivatedTab(){
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
try{
if(tabs[0]!=undefined){
console.log(tabs[0].url);
}
}
catch(err){
setTimeout(function() {
getActivatedTab();
},100);
}
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With