excaliburjs / excalibur-extension

Excalibur Dev Tools Browser Extension
https://chromewebstore.google.com/detail/excalibur-dev-tools/dinddaeielhddflijbbcmpefamfffekc
BSD 2-Clause "Simplified" License
2 stars 2 forks source link

Fix Excalibur extension losing connection until reload #5

Closed mattjennings closed 5 months ago

mattjennings commented 5 months ago

See discord thread for detailed findings.

The best way I was able to reproduce this issue was by:

this caused both my tab & the service worker to reload, however the dev tools panel remained open and so it lost the connection to the service worker. I couldn't find any way to find out when this connection was lost (no disconnect events or anything were fired), other than attempting a chrome.runtime.connect() again and catching the specific error.

If the error is caught, it simply does a window.location.reload to reload the panel (chrome.runtime.reload() did not work)

mattjennings commented 5 months ago

I suspect there may be another scenario where this connection gets lost without ever switching tabs from doing many page reloads (e.g. hot reloads from dev server), but I could not repro that as easily. For now, this connection check happens on page focus, but perhaps it's worth checking on an interval as well. I also don't know if there are any ramifications for calling chrome.runtime.connect() multiple times per lifecycle but it didn't seem to be an issue...