api/env: broadcast raw contents instead of parsed

This commit is contained in:
jj 2025-05-31 13:43:22 +00:00
parent 7fa3340a13
commit 57eba51959
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}
});
}