@omen.foundation/node-microservice-runtime 0.1.97 → 0.1.99

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.97",
3
+ "version": "0.1.99",
4
4
  "description": "Beamable microservice runtime for Node.js/TypeScript services.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -473,15 +473,11 @@ async function resolveGamePid(apiHost, token, cid, pid, explicitGamePid) {
473
473
  console.error(`[beamo-node] [STEP: Resolve Game PID]`);
474
474
  console.error(`[beamo-node] Explicit Game PID: ${explicitGamePid || '(none)'}`);
475
475
  console.error(`[beamo-node] Realm PID: ${pid}`);
476
+ console.error(`[beamo-node] NOTE: Always resolving root project (Game ID) from API, ignoring explicit value`);
476
477
  }
477
478
 
478
- if (explicitGamePid) {
479
- if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
480
- console.error(`[beamo-node] Using explicit game PID: ${explicitGamePid}`);
481
- }
482
- return explicitGamePid;
483
- }
484
-
479
+ // Always resolve the root project from the API (matching C# CLI's FindRoot().Pid)
480
+ // The explicit game PID might be incorrect (could be realm PID instead of root)
485
481
  const scope = pid ? `${cid}.${pid}` : cid;
486
482
  try {
487
483
  const url = new URL(`/basic/realms/game`, apiHost);
@@ -511,17 +507,35 @@ async function resolveGamePid(apiHost, token, cid, pid, explicitGamePid) {
511
507
  return pid;
512
508
  }
513
509
 
510
+ // Match C# CLI FindRoot() logic: walk up parent chain until Parent == null (root)
514
511
  const byPid = new Map(projects.map((project) => [project.pid, project]));
515
512
  let current = byPid.get(pid);
513
+ if (!current) {
514
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
515
+ console.error(`[beamo-node] Realm PID not found in projects, using realm PID: ${pid}`);
516
+ }
517
+ return pid;
518
+ }
519
+
516
520
  const visited = new Set();
517
- while (current && current.parent && !visited.has(current.parent)) {
521
+ // Walk up parent chain until we find root (parent == null or isRoot == true)
522
+ while (current && (current.parent != null && current.parent !== '' && !current.isRoot) && !visited.has(current.parent)) {
518
523
  visited.add(current.pid);
519
524
  current = byPid.get(current.parent);
525
+ if (!current) {
526
+ // Parent not found in projects list, current is as far as we can go
527
+ break;
528
+ }
520
529
  }
530
+ // current is now the root (or the original if no parent chain)
521
531
  const resolved = current?.pid ?? pid;
522
532
 
523
533
  if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
524
- console.error(`[beamo-node] Resolved Game PID: ${resolved}`);
534
+ console.error(`[beamo-node] Resolved Game PID (root): ${resolved}`);
535
+ if (explicitGamePid && explicitGamePid !== resolved) {
536
+ console.error(`[beamo-node] ⚠️ WARNING: Explicit Game PID (${explicitGamePid}) does not match resolved root (${resolved})`);
537
+ console.error(`[beamo-node] Using resolved root (${resolved}) for imageNameMD5 calculation`);
538
+ }
525
539
  }
526
540
  return resolved;
527
541
  } catch (error) {