I hope we can start having a look at it some time next week.
Original Message:
Sent: 06-10-2025 10:14
From: Johan Cantens
Subject: Disabling live reload config does not unwatch config file
Hello Jerome
Thank you for the update! is it possible to get a date ? Because this has quit some impact for us.
kind regards,
Johan
| | | Johan Cantens | | Senior Application Developer | | | | | | | Tiensesteenweg 168, bus 401 blok C, 3800 Sint-Truiden | | | | | | | | | |
Original Message:
Sent: 6/10/2025 9:57:00 AM
From: Jerome Saint-Marc
Subject: RE: Disabling live reload config does not unwatch config file
Hello,
Not yet. We are working on a round of features and issues. We should take a look at this one in the next round.
Regards,
------------------------------
Jerome Saint-Marc
Senior Development Support Engineer
Original Message:
Sent: 06-10-2025 06:54
From: Johan Cantens
Subject: Disabling live reload config does not unwatch config file
Hi Jerome
Do you have an update?
Regards, Johan
------------------------------
Johan Cantens
Independant Genesys Consultant & Data Architect
Original Message:
Sent: 05-22-2025 08:25
From: Jerome Saint-Marc
Subject: Disabling live reload config does not unwatch config file
Thank you. I'll bring this to the attention of the SDK team and will update this post when I have some news.
Regards,
------------------------------
Jerome Saint-Marc
Senior Development Support Engineer
Original Message:
Sent: 05-22-2025 02:50
From: Johan Cantens
Subject: Disabling live reload config does not unwatch config file
If it helps, this is my untested code changes that I think should fix the problem.
If you want I could test it properly and create a pull request.
diff --git a/build/src/purecloud-platform-client-v2/configuration.js b/build/src/purecloud-platform-client-v2/configuration.jsindex 36fe69d6..3c77cd80 100644--- a/build/src/purecloud-platform-client-v2/configuration.js+++ b/build/src/purecloud-platform-client-v2/configuration.js@@ -29,7 +29,7 @@ class Configuration { } this.refresh_access_token = true; this.refresh_token_wait_max = 10;- this.live_reload_config = true;+ this._live_reload_config = true; this.host; this.environment; this.basePath;@@ -39,6 +39,7 @@ class Configuration { this.logger = new Logger(); this.setEnvironment(); this.liveLoadConfig();+ this.listener = undefined; } liveLoadConfig() {@@ -51,11 +52,19 @@ class Configuration { if (this.live_reload_config && this.live_reload_config === true) { try { const fs = require('fs');- fs.watchFile(this.configPath, { persistent: false }, (eventType, filename) => {++ // This could happen if config path changed via setConfigPath()+ // Unsubscribe to previous listener so we aren't listening to multiple files+ if (this.listener) {+ this.listener.close();+ }++ this.listener = fs.watchFile(this.configPath, { persistent: false }, (eventType, filename) => { this.updateConfigFromFile();- if (!this.live_reload_config) {- fs.unwatchFile(this.configPath);- }+ // No longer needed because will unsubscribe in setter of live_reload_config+ // if (!this.live_reload_config) {+ // fs.unwatchFile(this.configPath);+ // } }); } catch (err) { // do nothing@@ -67,6 +76,18 @@ class Configuration { this.configPath = ''; } + set live_reload_config(enabled) {+ this._live_reload_config = enabled;++ if (!enabled && this.listener) {+ this.listener.close();+ }+ }++ get live_reload_config() {+ return this._live_reload_config;+ }+ setConfigPath(path) { if (path && path !== this.configPath) { this.configPath = path;

------------------------------
Johan Cantens
Independant Genesys Consultant & Data Architect
Original Message:
Sent: 05-22-2025 02:27
From: Johan Cantens
Subject: Disabling live reload config does not unwatch config file
Hi,
No config file and no reload.
But in the current implementation of the library the default config file is automatically watched in the constructor of Configuration.
Currently I can only disable auto reload after Configuration is initialized.
So I should be able to either:
- Specify earlier that I don't want to auto reload
- Or the file already being watched with fs.watchFile should be unwatched/closed when I disable auto reload so there are no unused open listeners in the node process.
Regards,
------------------------------
Johan Cantens
Independant Genesys Consultant & Data Architect
Original Message:
Sent: 05-21-2025 13:20
From: Jerome Saint-Marc
Subject: Disabling live reload config does not unwatch config file
Hello,
Are you trying to load the config from a file and not have auto/live reload?
Or no config file and no reload?
Regards,
------------------------------
Jerome Saint-Marc
Senior Development Support Engineer
Original Message:
Sent: 05-21-2025 05:45
From: Johan Cantens
Subject: Disabling live reload config does not unwatch config file
I'm using the purecloud platform sdk javascript client, and am trying to disable the live config reload.
In the README two ways to do this are documented.
1. Set `client.config.live_reload_config` to false
2. Set `live_reload_config` to false inside `.genesyscloudjavascript\config`
Method 1
If I disable it via **method 1**, it is already too late because live reload is already configured inside the `Configuration` constructor:
const client = new platformClient.ApiClientClass(); // <=== Live reload already triggered here
client.config.live_reload_config = false;
Relevant source code is here.
This is problematic because live reload calls `fs.watchFile` and will never call `fs.unwatchFile` which eventually can lead to these kind of errors:
(node:12724) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added to [StatWatcher]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
try {
const fs = require('fs');
fs.watchFile(this.configPath, { persistent: false }, (eventType, filename) => {
this.updateConfigFromFile();
if (!this.live_reload_config) {
fs.unwatchFile(this.configPath); // <=== Never called
}
});
}
Method 2
If I disable it via **method 2**, it works but **only** if I use the config file in the default location. If I use a different location (which should work via `client.config.setConfigPath(/*location*/)`), it does not work because again the default file is already being watched in the constructor of `Configuration`.
So if I set `live_reload_config` to false in the non-default config file. The file will be watched and immediately unwatched, **which is correct**:
fs.watchFile(this.configPath, { persistent: false }, (eventType, filename) => {
this.updateConfigFromFile();
if (!this.live_reload_config) {
fs.unwatchFile(this.configPath); // <=== New config file will be unwatched
}
});
**BUT** the default file is still being watched (and will trigger updates if it changes?) and never unwatched, leading to the same problem of unclosed resources.
Conclusion
Is there any way to completely disable live reload config? I want to disable it because I don't use it, and leads to unclosed resources because fs.unwatch is not called.
#PlatformSDK
------------------------------
Johan Cantens
Independant Genesys Consultant & Data Architect
------------------------------