-
-
Notifications
You must be signed in to change notification settings - Fork 48
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 broken with historyFallback in Firefox #94
Comments
By changing configuration to the following: new Serve({
// note: this value is true by default
hmr: true,
historyFallback: {
logger: console.log.bind(console),
verbose: true,
},
static: [outputPath]
}) I found that when loading
While the following behavior happens in Chrome:
|
Not sure if this is the most optimal, but it can be fixed with the following configuration: new Serve({
// note: this value is true by default
hmr: true,
historyFallback: {
logger: console.log.bind(console),
verbose: true,
},
middleware: (app, builtins) => app.use(async (ctx, next) => {
if (ctx.path.match(/^\/wps/)) {
const { accept, ...remainingHeaders } = ctx.request.header
ctx.request.header = remainingHeaders
}
await next()
}),
static: [outputPath]
}) EDIT: a simpler approach new Serve({
// note: this value is true by default
hmr: true,
historyFallback: {
// disable the plugin on /wps
rewrites: [
{
from: '/wps',
to: (context) => (context.parsedUrl.pathname),
},
],
},
static: [outputPath]
}) |
@davidroeca would you classify this as a problem with WPS or with http-proxy-middleware directly? |
@shellscape well actually, it's most likely an issue with how |
Ah yeah, that's what I meant :) mental lapse there. Could this be related? bripkens/connect-history-api-fallback#60 |
Somewhat related, though Firefox sends along an So I guess for now it's a bug specific to websockets in firefox, which passes along an |
Thanks for the explanation. Do you have any suggestions for how we should best handle this? |
Maybe an option for the |
That would require using a separate WebSocket Server, something that we explicitly tried to avoid because of the complications and overhead it created. Unfortunately that's not an option for this plugin. I can definitely add a FAQ question for this. But I'd be curious to know about any other ideas you have. If adding the middleware from your reply above fixes the issue, I'm open to making that a permanent addition as well. |
Yeah I mean implementing a middleware that gets around this definitely makes sense to me as long as it doesn't make the plugin code too confusing. Maybe by default this middleware behavior is turned on but there could be a configuration option to turn it off if it causes people problems? It would probably be worth documenting this behavior as it relates to |
Sounds like a plan to me. I'll get this implemented. |
How Do We Reproduce?
With the given Firefox versions, run the react recipe in this repo.
Expected Behavior
HMR works as expected with
historyFallback
on Firefox. This is especially important if I'm developing an app that relies on something like https://github.com/ReactTraining/react-router for SPA purposes.Actual Behavior
Notice in the console that the following error occurs:
Firefox can’t establish a connection to the server at ws://[::]:55555/wps.
.Now kill the start script, remove the
historyFallback
option and restart. The bug now should be fixed.Note that this problem does not exist on current versions of Chrome/Chromium.
The text was updated successfully, but these errors were encountered: