Skip to content

fix(config): implement cached config fallback on load failure#189

Open
hdkiller wants to merge 7 commits intohywax:mainfrom
hdkiller:fix/config-loading-resilience
Open

fix(config): implement cached config fallback on load failure#189
hdkiller wants to merge 7 commits intohywax:mainfrom
hdkiller:fix/config-loading-resilience

Conversation

@hdkiller
Copy link
Contributor

This PR introduces a caching mechanism to the configuration loader to improve stability.

Problem:
Currently, if the configuration file update fails or is momentarily inaccessible (e.g., during a write operation), the application throws a 500 error immediately after retries fail.

Solution:

  • Implemented a cachedConfig variable in src/server/utils/config.ts.
  • When a config is successfully loaded, it is cached.
  • If loadConfig fails (even after retries), it now checks for a cached version.
  • If a cached version exists, it is returned with a warning log, keeping the application running with the last known good state.
  • If no cache exists (e.g. startup failure), the original error behavior is preserved.

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 this pull request may close these issues.

1 participant