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
If sockHost is not specified, overlay will try to connect to 3rd party server hosting other scripts on the page #554
Comments
Reading through the code, it seems like setting |
It should probably have the same behaviour as WDS, I'll take a look at why this was breaking. |
Hi, it's been a while but I tried looking at this and I cannot see how our implementation would break - in particular, if |
I think webpack works for me and this plugin has the issue due to how I load files on the page (webpack stuff gets loaded after document.onload and doesn't have any third party scripts coming in at the time). At the very least, the documentation for sockhost should be updated as it states that the default host is |
Can you provide a reproducible example for me to better understand the situation? The options try to mimic the behaviour of WDS as close as we can get, and under normal circumstances host from |
@pmmmwh I'll see what I can do for an example. In my specific case I have an externalized react (https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#externalising-react). I bundle the plugin with the react library itself. Our page loading order goes something like:
The plugin is loading in step 2 along with google-analytics, facebook, etc. and thus document.currentScript often picks up one of them. I know this is more of an edge case for you and is somewhat atypical. I'm not arguing that We both agree the documentation for sockhost is incorrect, right? We both agree that getting the hostname from document.currentScript != window.location.hostname, right? We both agree it would be helpful to document that the address '0.0.0.0' is a special case triggering unique behavior? I just feel incorrect docs are worse than no documentation at all. It took me a couple hours to figure out what was happening because I believed the documentation and I don't want that to happen to other people. I'll be happy to make a pr to update the documentation if you like. |
The point is, I'm not opposing the idea of changing the documentation, in fact I would welcome PRs for it, but I would also like to highlight that these options are soon to be deprecated because direct integration with WDS is now possible. (However, I also think this plug-in's chunks should load AFTER WDS anyways, and potentially not |
Not to say the current documentation text is correct but to give more context:
|
This will be fixed in #630 and should be released soon. |
Using the latest version of the plugin (0.5.4)
I'm initializing like:
The url of the page:
http://localhost:3000/
Webpack dev server is on localhost:1887.
The console will show an error opening a web socket to a third party server (e.g.,
wss://googleads.g.doubleclick.net:1887/ws
, but the host of other third party scripts used on the page is seen frequently as well) instead of localhost. According to the docs, the default should bewindow.location.hostname
. This error seems to be related to usage of this plugin (changing settings as described below resolves the issue).While not happening every time I load a page, the error happens very frequently. Manually setting
sockHost
to 'localhost' makes it so the connection always goes to localhost, however it uses wss instead of ws (which I think is related to the third party scripts being loaded with https instead of http like the main page). So I also need to hardcodesockProtocol
to 'ws'. Once I do this it works 100% (but I shouldn't need to according to the docs, and I don't want to hardcode these values).The web socket established by webpack-dev-server (4.7.2) always establishes correctly -- only the socket established by this plugin has intermittent issues.
The text was updated successfully, but these errors were encountered: