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

Non-Reactive Behavior of NestJS ConfigService with Dynamic Environment Variable Updates #1476

Closed
1 task done
abbasatayee opened this issue Sep 25, 2023 · 3 comments · Fixed by #1575
Closed
1 task done

Comments

@abbasatayee
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

The ConfigService in NestJS does not seem to react to changes in environment variables. When I update an environment variable externally (e.g., using Node.js), the ConfigService retains the old values and does not reflect the updated values.

process.env.ABC=abc

Describe the solution you'd like

I would like to request the addition of a set method to the NestJS ConfigService. This method should allow for the dynamic updating of both environment variables and the corresponding values in the ConfigService, ensuring that they stay in sync.

Example Usage:

import { ConfigService } from '@nestjs/config';

@Injectable()
export class MyService {
  constructor(private readonly configService: ConfigService) {}

  updateConfigValue() {
    // Update the 'DATABASE_HOST' configuration variable and keep the ConfigService in sync.
    this.configService.set('DATABASE_HOST', 'new-host-value');
  }
}

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Avoiding Anti-Patterns and Promoting Consistency

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@abbasatayee
Copy link
Author

Would you like to create a PR for this issue?

Sure
I will create a PR

@kamilmysliwiec
Copy link
Member

Let's track this here #1575

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants