chrome extension Error: attempting to use a disconnected prot object

if you get this error:
  1. Port error: Could not establish connection. Receiving end does not exist. miscellaneous_bindings:236
    1. chromeHidden.Port.dispatchOnDisconnectmiscellaneous_bindings:236
  1. Uncaught Error: Attempting to use a disconnected port object miscellaneous_bindings:58
    1. PortImpl.postMessagemiscellaneous_bindings:58
    2. xhr.onreadystatechange
That means you have make some mistake as this discussed:

This is caused when a connection get closed. For example if you open a tab that has the content_script injected, it opens a connection, the tab is closed, and then the background_page tries to pass a message. It will fail because the tab is no longer active to receive the message.
In your case I would guess that as tabs close and new tabs open you are attempting to post messages with the old tabId instead of creating a new connection to the new tab. I would recommend reading through the long-lived connections section again.