-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Updates require multiple file saves #36
Comments
Have you tried running this with the default dev and hot config? It may be a pain, but to determine which module is breaking you could deconstruct koa-webpack and manually wrap and add the middleware in your app. That'd root out the possibility that it's an issue with composing the two. On the surface this looks like it might be a problem with webpack-hot-middleware. I'll have a look at the boilerplate later on this evening, thanks for linking to that. |
Yeah, I started without the custom path and added it for debugging. It makes no difference.
I'd have no idea how to wire up koa2 to the express middleware without the passthrough stream! I've rebuilt the middleware internally to my app so I can debug and remove options that aren't appropriate for my use case but still the same issue. I can debug all the way down to webpack-hot-middleware and see that it's publishing the
Thanks that would be really appreciated. I've pushed a new commit on the |
Well the good news is that you're not 🍌 s. I was able to replicate the problem last night. The bad news is that I couldn't come up with a solid reason as to why. An idea a friend proposed was to use a 3rd party file listener module as middleware and publish the update event to hot-middleware manually. That really shouldn't be necessary, but I can't figure out the why part of it not working correctly. |
I did more digging and think it's related to |
@tomatau fascinating. when removing that middleware, was everything working as it should? And if so, I wonder if that begs the question of if we can do something to recognize that and compensate for it, outside of the webpack-* middleware. |
koa-compress under the hood is using a library called compressible. Compressible see's that the responses content type contains The simple fix I've done here is: app.use(compress({
filter: type => !(/event\-stream/i.test(type)) && compressible(type),
})) There is a way to disable compression using |
yeah, agreed that it's very specific to koa-compress. I can add a note to the README point to this issue and your last comment for users of that middleware. sound good? |
Yep sounds good |
Thanks for working through this one, I've no doubt it'll help some folks out down the road with a similar setup. |
Just a quick note about the performance of the work around; you can increase performance a bit by storing the regexp literal into a const, so it doesn't have to be compiled more than once during runtime. |
… inside and I believe there is nothing wrong with koa-compress or compressible shellscape/koa-webpack#36 (comment)
@talha-asad Were you able to make your approach work with koa? Would you mind sharing a gist or code sample? |
Server integration:
https://github.com/tomatau/breko-hub/blob/koa2/src/helpers/hotReload.js#L24-L38
Actual Behavior
After making any file change, my server is logging
But sometimes the client logs nothing. However, if I repeatedly save the file (without changes), eventually my client will log
How can we reproduce the behavior?
Clone this branch on this boilerplate repository: https://github.com/tomatau/breko-hub/tree/koa2
Ensure you have a
.env
file with NODE_ENV=development. Enable the debugger (sensible defaults in example.env). Runnpm start
and make multiple file changes to any react component.You can see a "Webpack compile started..." for each file save, but only eventually does the request come through for the hot-update chunks.
Notes
Thanks for making this library. I originally tried koa-webpack-middleware but it was breaking mime types as the hot middleware set octetstream on every response.
My boilerplate (linked) was working fine in every way for hot reloading (even server side live updates and hot updates of css-modules). I have made the minimal changes to migrate to koa2 and debugging this issue has left me stumped. I have thrown logs all over
webpack-hot-middleware
s client middleware and server middleware and can see the server sending messages but the client only receiving a subset of them. Eventually if I CMD+S on my file enough times after making a change the client will update.This may be a more appropriate issue for webpack-hot-middleware but that repository seems less responsive to issues.
The text was updated successfully, but these errors were encountered: