@omen.foundation/node-microservice-runtime 0.1.83 → 0.1.85

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.83",
3
+ "version": "0.1.85",
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
 
@@ -509,16 +509,16 @@ async function uploadDockerImage({
509
509
  progress,
510
510
  }) {
511
511
  const baseUrl = `${registryUrl}${uniqueName}/`;
512
- // Match C# CLI exactly: use x-ks-* headers (all lowercase) with CID, PID (realm PID), and access token
513
- // Note: Backend might check using gamePid, but C# CLI uses realm PID for upload headers
512
+ // Try using gamePid in headers - backend checks registry using game PID scope
513
+ // The uniqueName is calculated with gamePid, so headers should match
514
514
  const headers = {
515
515
  'x-ks-clientid': cid,
516
- 'x-ks-projectid': pid, // Use realm PID (not gamePid) - matches ctx.Pid in C# CLI
516
+ 'x-ks-projectid': gamePid || pid, // Use gamePid if available, fallback to realm PID
517
517
  'x-ks-token': token, // Access token from login
518
518
  };
519
519
  if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
520
520
  console.error(`[beamo-node] Uploading to: ${baseUrl}`);
521
- console.error(`[beamo-node] Upload headers PID: ${pid} (realm), gamePid: ${gamePid}`);
521
+ console.error(`[beamo-node] Upload headers PID: ${gamePid || pid} (gamePid: ${gamePid}, realm: ${pid})`);
522
522
  }
523
523
 
524
524
  const { manifestEntry, configBuffer, layers } = await readDockerImageTar(imageTarPath);
@@ -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 || {};
@@ -1119,6 +1134,32 @@ async function main() {
1119
1134
  });
1120
1135
  progress.complete('Image uploaded');
1121
1136
 
1137
+ // Verify image exists in registry before proceeding
1138
+ const shortImageId = shortDigest(fullImageId);
1139
+ const baseUrl = `${registryUrl}${uniqueName}/`;
1140
+ const verifyHeaders = {
1141
+ 'x-ks-clientid': cid,
1142
+ 'x-ks-projectid': resolvedGamePid || pid, // Use gamePid to match registry scope
1143
+ 'x-ks-token': token,
1144
+ };
1145
+
1146
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
1147
+ console.error(`[beamo-node] Verifying image exists: ${baseUrl}manifests/${shortImageId}`);
1148
+ console.error(`[beamo-node] Verify headers:`, verifyHeaders);
1149
+ }
1150
+
1151
+ // Wait a moment for registry to propagate
1152
+ await new Promise(resolve => setTimeout(resolve, 3000));
1153
+
1154
+ const imageExists = await verifyManifestExists(baseUrl, shortImageId, verifyHeaders);
1155
+ if (!imageExists) {
1156
+ throw new Error(`Image verification failed: manifest with tag ${shortImageId} not found in registry at ${baseUrl}manifests/${shortImageId}. The image may not have uploaded successfully.`);
1157
+ }
1158
+
1159
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
1160
+ console.error(`[beamo-node] ✓ Image verification passed: ${baseUrl}manifests/${shortImageId}`);
1161
+ }
1162
+
1122
1163
  // Step 7: Discover storage, components, and dependencies
1123
1164
  progress.start('Discovering storage objects and components');
1124
1165
  const shortImageId = shortDigest(fullImageId);