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
ServerMiddleware hot reload is faulty #9456
Comments
Thanks for your contribution to Nuxt!
Issues that are labeled as |
No, bad bot |
I have the same problem currently and it makes developing a Mongoose backend very unpleasant. I have to manually exit and restart Nuxt everytime I make a change in any server file. |
We are aware of this issue and it's not that easy to fix. We have a solution coming with the Nuxt Nitro module. will keep this issue updated. |
Hi, I am now experiencing the same problem as mentioned by @Susccy & @AregGhazaryan - I have tried the workaround in #7917 which has not worked as well as upgrading to Nuxt 2.15.8. @Susccy Did you manage to fix this? I am also having to manually refresh my Mongoose backend everytime. Is there any update on this please? Thanks. |
@TomBell95 The following workaround makes hot reloading possible in my current mongoose project. Keep in mind you'll have to restart the app every time you make changes to the model. // movie.model.js
import { Schema, models, model } from "mongoose"
const movieSchema = new Schema({
// ...
})
// Try to use the existing model if it's been created before.
// Used to suppress a mongoose error on nuxt hot reload.
export default models.Movie || model("Movie", movieSchema) |
@Susccy Brilliants, thanks. |
Thanks for your contribution to Nuxt!
Issues that are labeled as |
Versions
Reproduction
https://github.com/AregGhazaryan/nuxt-mongoose-server-middleware-reprod
Steps to reproduce
What is Expected?
Server middleware should reload with latest changes without throwing errors.
What is actually happening?
The entire server middleware re-instantiates including, classes, functions and other resources. I can assure you that issue is not only mongoose related, because once i even had a telegram bot connected to my application which threw similar errors, like two instances are being run instead of just one.
The text was updated successfully, but these errors were encountered: