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

Switch inject-socket to use getSocketHostname #758

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Switch inject-socket to use getSocketHostname #758

merged 1 commit into from
Sep 8, 2023

Conversation

kadhirvelm
Copy link
Contributor

Details

In two previous PRs, support for changing the HMR host and serve host were added:
#745
fa6045e

Unfortunately, the HMR was still not working when binding to 0.0.0.0. After some exploration, one culprit is that the content script UI isn't successfully connecting to the HMR server. The function it was using to get the hostname of the HMR server would return the location's hostname where the content script was opened on. This PR adds a new function that ensures when fetching the hostname for a socket, it returns "localhost" by default instead of the location's hostname.

I've tested this method of getting the hostname for the socket connection is working in content script UIs and the background worker.

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I agree to license this contribution under the MIT LICENSE
  • I checked the current PR for duplication.

@@ -59,6 +59,14 @@ export function getHostname() {
return runtimeData.host
}

export function getSocketHostname() {
if (!runtimeData.host || runtimeData.host === "0.0.0.0") {
return "localhost";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth mentioning that attempting to connect to 0.0.0.0 from a content script UI results in this error:
image

Copy link
Contributor

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@louisgv louisgv added this pull request to the merge queue Sep 8, 2023
Merged via the queue into PlasmoHQ:main with commit b431398 Sep 8, 2023
1 check passed
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