wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
13.49k stars 1.18k forks source link

Creating files programmatically on the server (e.g. via API hit) triggers reloading #1881

Open GavPierce opened 7 months ago

GavPierce commented 7 months ago

Whenever I hit a custom API in my server code in local dev, it recompiles the entire app, refreshing of course the client server page and losing all state, every time I make an API call.

This should only be happening on actual file changes, why is it happening now? And how can I turn off reloading?

vincanger commented 7 months ago

hmmm that sounds like a bug. what wasp version are you on? if you can share the api definition in the wasp file as well as the function its importing, that would be helpful @GavPierce

Martinsos commented 6 months ago

Yup this sounds super weird! @GavPierce can you share more info? Maybe a version of app that we can use to reproduce the bug?

GavPierce commented 6 months ago

This issue seems to be caused when an endpoint creates a new file on the server, which makes sense, but there should be the ability to turn off HMR, or HMR should not happen when a new file is created.

Martinsos commented 6 months ago

This issue seems to be caused when an endpoint creates a new file on the server, which makes sense, but there should be the ability to turn off HMR, or HMR should not happen when a new file is created.

Oh all right, that makes sense!

Hmmm, what could be the ideal experience here? So these files your API checkpoint is creating -> they should be under .gitignore, I am sure you don't want them versioned. I guess you do have them under .gitignore? But they are still being watched, right?

So watching in our case, for the server, is being done by nodemon in the background.

There are multiple ways to get nodemon to ignore some files: directly by passing it flag via CLI, setting it up in package.json, or having nodemon.json file: https://stackoverflow.com/questions/41913086/nodemon-ignore-directory . I am not sure if you can actually do any of these right now via Wasp though, I think not, as nodemon is too much in the background. But we could expose a way to do it via Wasp in the future.

Martinsos commented 6 months ago

I updated the title to be more precise and also moved it to Wasp repo since this is not open-saas specific.