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

HMR fails to connect when linked externally. #6061

Open
timdorr opened this issue Mar 27, 2021 · 4 comments
Open

HMR fails to connect when linked externally. #6061

timdorr opened this issue Mar 27, 2021 · 4 comments
Labels

Comments

@timdorr
Copy link

timdorr commented Mar 27, 2021

🐛 bug report

Since #6005 landed, I am unable to use HMR with Parcel acting as an external server. That is, I have another server that renders our HTML and includes the Parcel build output via a <script> tag. It uses the port of the HTML rendering server when trying to connect to the HMR WebSocket.

🎛 Configuration (.babelrc, package.json, cli command)

CLI command:

yarn parcel serve client/index.tsx --https --cert ./tls.crt --key ./tls.key
<script defer src="https://localhost:1234/index.js"></script>

🤔 Expected Behavior

It should use the port number explicitly in the generated output for the HMR runtime.

😯 Current Behavior

My HTML rendering server runs on port 10000, so I get this message in my browser:

WebSocket connection to 'wss://localhost:10000/' failed: 

💁 Possible Solution

Side note: I noticed that --hmr-port does set the port in the runtime, but doesn't actually open a server on that port for updates. That might be a possible solution.

Maybe add a --no-hmr-port option to resolve the issue #6005 was trying to address, but revert the change for the default case.

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.631
Node 14.15.1
npm/Yarn yarn@1.22.10
Operating System macOS Big Sur
@mischnic
Copy link
Member

So all combinations I can think of are:

  1. parcel serve and opening http://localhost:1234/index.html
  2. parcel watch and bringing your own HTTP server
  3. 1 but proxied (e.g. ngrok) to a different domain/port (https://abc.ngrok.io), ideally http://localhost:1234 would still work fine
  4. 1 but serving HTML youself (Parcel serves JS)

@101arrowz
Copy link
Member

101arrowz commented Oct 21, 2021

I just found that #6005 also breaks HMR for web extensions with serve because location.port doesn't actually work in an extension context. I guess a working solution is to specify a different --hmr-port but it's not optimal.

EDIT: After looking again everything is fine with watch but sometimes you like to debug the extension pages from a web context instead of using the extension directly.

@drmercer
Copy link

drmercer commented Mar 6, 2022

What I'm seeing on a fresh install (version 2.3.2) after following the official Web Extension recipe:

@101arrowz
Copy link
Member

@drmercer Have you been doing parcel watch --hmr-port 5678 or any other port? That worked when I last tried it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants