In my extension I'm trying to attach debugger for given tabId, Here is my code
if(!attachedTabIds.includes(tabId)) {
chrome.debugger.attach({ tabId: tabId }, version, function(){
...
})
}
So from time to time I'm getting this error
I tried to wrap it with try/catch block but it didn't work.
try {
chrome.debugger.attach({ tabId: tabId }, version, function(){
...
})
} catch(e){
console.log('e', e)
}
SO how can I handle this error ?

You handle the error by checking the value of
chrome.runtime.lastErrorin the callback function that you passed tochrome.debugger.attach()https://developer.chrome.com/docs/extensions/reference/runtime/#property-lastError