Skip to content

best way to save what you love

api/env: broadcast raw contents instead of parsed

jj57eba519599f
diff --git a/api/src/config.js b/api/src/config.js
index a5ebf3d6..058db83b 100644
--- a/api/src/config.js
+++ b/api/src/config.js
@@ -19,8 +19,6 @@ export const updateEnv = (newEnv) => {
for (const key in env) {
env[key] = newEnv[key];
}
-
- cluster.broadcast({ env_update: newEnv });
}
await validateEnvs(env);
diff --git a/api/src/core/env.js b/api/src/core/env.js
index 4e41760c..35c892f9 100644
--- a/api/src/core/env.js
+++ b/api/src/core/env.js
@@ -113,8 +113,9 @@ export const validateEnvs = async (env) => {
const reloadEnvs = async (contents) => {
const newEnvs = {};
+ const resolvedContents = await contents;
- for (let line of (await contents).split('\n')) {
+ for (let line of resolvedContents.split('\n')) {
line = line.trim();
if (line === '') {
continue;
@@ -138,6 +139,7 @@ const reloadEnvs = async (contents) => {
const parsed = loadEnvs(candidate);
await validateEnvs(parsed);
updateEnv(parsed);
+ cluster.broadcast({ env_update: resolvedContents });
}
const wrapReload = (contents) => {
@@ -182,7 +184,7 @@ export const setupEnvWatcher = () => {
} else if (cluster.isWorker) {
process.on('message', (message) => {
if ('env_update' in message) {
- updateEnv(message.env_update);
+ reloadEnvs(message.env_update);
}
});
}