-
Notifications
You must be signed in to change notification settings - Fork 197
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
[Bug]: Hot Reload Not Re-enabled When Switching from Production to Development Mode #2457
Comments
While yes we did consider "Production" -> "Development" mode as part of the scope, this change becomes difficult because there are checks in DAB that evaluate "IsHotReloadEnabled()" which considers dev/prod mode and forbids hot reload when in prod mode. You'd need to signal to hot reload functions that the "Mode" is explicitly changing. If building in support for this, I'd recommend ensuring that the change includes logging that indicates hot reload is occurring because of a dev/prod mode switch. Also would be beneficial to check dev mode to prod mode hot reload scenario. There are some instances in startup that are conditioned on Dev mode/prod mode only and those may be skipped when switching mode via hot reload as startup has already completed. |
I gave more thoughts on this and believe its best to keep the existing functionality as this forces a conscious decision to re-enable hot reload and reduces risks associated with inadvertent switches or malicious toggles. This also aligns with the fact that we retain the scenario when starting the engine with production, switching to development doesn't enable hot-reload automatically. |
We can close this issue then if we want to keep the current functionality. If we decide to change back in the future, because the ability to hot-reload would be gated behind starting the engine in dev mode, it should be "safe" to simply use the built-in functions we have for determining of it is OK to hot-reload or not. This is because if the engine is started in production, file watching will never happen and so there is no danger of somehow a hot-reload doing something unsafe to an instance of DAB. We should be clear when we communicate to customers that for production scenarios, DAB should always be started in production, not hot-reloaded into production. For cases where DAB was started in dev mode, but switched to production, the built-in functions should suffice, since for example when we determine if we should override the open API document, this happens downstream of the hot-reload logic: So regardless of the mode that the runtime is actually in, which can be arbitrary if the user can swap back and forth with hot-reload, we are always going to over-write the open API document, because we are always in a hot-reload possible scenario, and we know that because we only ever file-watch when the engine is started in dev mode. So all we have to do is remove any kind of check from the hot-reload logic that looks at the mode. We don't care, we can only ever file monitor if we are starting the engine in dev, so the change is very easy, we just remove the part that checks mode before a hot-reload. Would love to hear your thoughts, @JerryNixon |
Some updates after we had a discussion in a sync up. The current functionality really doesn't make sense. If you start DAB in development mode, then you switch to production mode, you risk having things that are setup for dev mode infiltrating your production scenario. So, if we want to prevent that from happening, the solution is not to prevent hot-reload out of production mode, it is to prevent the hot-reloading of mode altogether. This means the two options that make the most sense would be:
|
I would support the second option considering the below factors:
|
What happened?
When updating the environment mode from development to production, hot reload is disabled, which is expected behavior. However, when the environment is subsequently changed back from production to development, hot reload is not re-enabled. This behavior is not expected; ideally, if the initial mode was development, hot reload should automatically reactivate when the mode is reverted to development.
Steps to Reproduce:
Expected Behavior:
Hot reload should be re-enabled automatically when the environment is set back to development mode.
Actual Behavior:
Hot reload remains inactive after switching from production to development mode.
Version
1.3.13-rc
What database are you using?
Azure SQL
What hosting model are you using?
Local (including CLI)
Which API approach are you accessing DAB through?
No response
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: