Skip to content
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

extension auto reload only works if NODE_ENV !== 'development' #13025

Closed
meytin1337 opened this issue Apr 27, 2022 · 6 comments
Closed

extension auto reload only works if NODE_ENV !== 'development' #13025

meytin1337 opened this issue Apr 27, 2022 · 6 comments

Comments

@meytin1337
Copy link

Describe the Bug

I was wondering why the extension auto reloading didn't work for me. I dug into the codebase and found this line of code in directus/api/src/:

const defaultOptions: Options = {
	schedule: true,
	watch: env.EXTENSIONS_AUTO_RELOAD && env.NODE_ENV !== 'development',
};

I don't think this is what the code is supposed to be since the primary use case for the extension auto reloading should be a development environment.

To Reproduce

In the environment where you run your directus instance set the environment variables

EXTENSIONS_AUTO_RELOAD=true
NODE_ENV=development

Errors Shown

No response

What version of Directus are you using?

9.9.1

What version of Node.js are you using?

16.14.2

What database are you using?

postgres

What browser are you using?

firefox

How are you deploying Directus?

docker

@meytin1337
Copy link
Author

I have create a PR here: #13027

@rijkvanzanten
Copy link
Member

This is correct, as we don't want the auto reload to kick in when running Directus from source through npm run dev as that is already handled by ts-node-dev 👍🏻

@Anoesj
Copy link

Anoesj commented Nov 24, 2022

@rijkvanzanten It would be nice to see whenever extensions are reloaded in the logs when NODE_ENV=development. I found this issue because I was confused why my extensions weren't reloading. In fact, you're saying the reload mechanism should still work in dev mode? Because that doesn't seem to work right now (Directus v9.21.0).

@rijkvanzanten
Copy link
Member

rijkvanzanten commented Jan 11, 2023

I believe the original intention for the reliance on NODE_ENV=development was to make sure that extensions weren't "double reloaded" when using the ts-node-dev based dev mode in the source code. Feels like it might be better to decouple that from NODE_ENV completely to remove any confusion as to wth is going on here 😁 cc @nickrum

@Anoesj
Copy link

Anoesj commented Jan 12, 2023

I agree! Less exceptions = less confusion 😄

@nickrum
Copy link
Member

nickrum commented Apr 11, 2023

I believe the original intention for the reliance on NODE_ENV=development was to make sure that extensions weren't "double reloaded" when using the ts-node-dev based dev mode in the source code.

That was exactly the original intention 👍

The root of the problem is that NODE_ENV == development could either mean that you are running Directus in dev mode to work on Directus itself or it could mean that you are running your own software that relies on Directus in dev mode. I think at some point we had a DIRECTUS_DEV env var. Maybe we should reintroduze that 🤔

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants