Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Excalibur extension losing connection until reload #5

Merged
merged 1 commit into from
Jun 9, 2024

Conversation

mattjennings
Copy link
Contributor

See discord thread for detailed findings.

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

  • loading a game with excalibur tools open
    • right-click -> inspect on the pane while you're at it to get the console logs
  • open up a new tab, say google.com
  • navigate to a new page

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
Copy link
Contributor Author

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...

@eonarheim eonarheim merged commit b95b3f7 into excaliburjs:main Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants