Skip to content

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

Closed
@abbasatayee

Description

@abbasatayee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions