@omen.foundation/node-microservice-runtime 0.1.82 → 0.1.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omen.foundation/node-microservice-runtime",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
4
4
  "description": "Beamable microservice runtime for Node.js/TypeScript services.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -61,7 +61,8 @@ async function main() {
61
61
 
62
62
  if (args.envFile) {
63
63
  const envPath = path.resolve(args.envFile);
64
- dotenv.config({ path: envPath });
64
+ // Use override: true to ensure .env file values override any existing environment variables
65
+ dotenv.config({ path: envPath, override: true });
65
66
  }
66
67
 
67
68
  if (args.cid) {
@@ -151,7 +151,7 @@ function parseArgs(argv) {
151
151
  }
152
152
  }
153
153
 
154
- if (!args.envFile && process.env.npm_config_env_file) {
154
+ if (process.env.npm_config_env_file) {
155
155
  args.envFile = process.env.npm_config_env_file;
156
156
  }
157
157
 
@@ -981,11 +981,26 @@ ENTRYPOINT ["/beam/service/start.sh"]
981
981
  }
982
982
 
983
983
  async function main() {
984
- const args = parseArgs(process.argv.slice(2));
985
-
986
- if (args.envFile) {
987
- dotenv.config({ path: path.resolve(args.envFile) });
984
+ // Parse --env-file first so we can load .env before parseArgs reads environment variables
985
+ // This ensures .env file values are used instead of stale system environment variables
986
+ const rawArgs = process.argv.slice(2);
987
+ let envFile = undefined;
988
+ for (let i = 0; i < rawArgs.length; i++) {
989
+ if (rawArgs[i] === '--env-file' && i + 1 < rawArgs.length) {
990
+ envFile = rawArgs[i + 1];
991
+ break;
992
+ }
988
993
  }
994
+
995
+ // Load .env file first with override to ensure it takes precedence
996
+ if (envFile) {
997
+ dotenv.config({ path: path.resolve(envFile), override: true });
998
+ } else if (process.env.npm_config_env_file) {
999
+ dotenv.config({ path: path.resolve(process.env.npm_config_env_file), override: true });
1000
+ }
1001
+
1002
+ // Now parse all args - env vars from .env will be available
1003
+ const args = parseArgs(rawArgs);
989
1004
 
990
1005
  const pkg = await readJson(path.resolve('package.json'));
991
1006
  const beamableConfig = pkg.beamable || {};
@@ -1091,10 +1106,10 @@ async function main() {
1091
1106
  }
1092
1107
  }
1093
1108
 
1094
- // Try using realm PID for registry URL (backend might check using realm PID scope)
1095
- // If resolvedGamePid differs from pid, the backend might be checking with the wrong scope
1096
- const registryUrl = await getRegistryUrl(apiHost, token, cid, pid);
1097
- const uniqueName = md5Hex(`${cid}_${pid}_${serviceId}`).substring(0, 30);
1109
+ // Use resolvedGamePid for registry URL and uniqueName - backend checks using game PID scope
1110
+ // The pid variable might be a realm PID, but the backend expects game PID for registry operations
1111
+ const registryUrl = await getRegistryUrl(apiHost, token, cid, resolvedGamePid);
1112
+ const uniqueName = md5Hex(`${cid}_${resolvedGamePid}_${serviceId}`).substring(0, 30);
1098
1113
  if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
1099
1114
  console.error(`[beamo-node] Registry URL: ${registryUrl}`);
1100
1115
  console.error(`[beamo-node] Unique name: ${uniqueName}`);