How to troubleshoot extension when it behaves differently while developer console is opened?

27 Views Asked by At

My extension opens a "panel" type popup which displays a collapsed list of data. User can manually extend the list. The problem I've discovered is if user extended the list, after few seconds of inactivity the list gets automatically collapsed. It's like the popup is being reloaded.

As soon as I open devtools, the problem disappears and no longer reproducible. One thing I've noticed in the browser extensions page, my extension become "inactive" a moment before action popup reloads and it remains "inactive" after I expand the list, yet it still automatically collapses after a few seconds.

So, how do I troubleshoot this?

1

There are 1 best solutions below

0
On

I found what was the issue.
My popup communicates with service worker via chrome.runtime.connect.
It has a onDisconnect listener, that launches popup initialization function when service worker become inactive, which essentially reloads the popup.

So, to answer my own question, since the issue was related to service worker become inactive, but only when devtools is not opened, we can force suspend service worker either via chrome://serviceworker-internals/ or via devtools -> Application -> Service workers -> stop button

Reference