@omen.foundation/node-microservice-runtime 0.1.79 → 0.1.81

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.79",
3
+ "version": "0.1.81",
4
4
  "description": "Beamable microservice runtime for Node.js/TypeScript services.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -281,6 +281,19 @@ async function checkBlobExists(baseUrl, digest, headers) {
281
281
  return response.status === 200;
282
282
  }
283
283
 
284
+ async function verifyManifestExists(baseUrl, tag, headers) {
285
+ const url = new URL(`manifests/${tag}`, baseUrl);
286
+ const response = await fetch(url, { method: 'HEAD', headers, redirect: 'manual' });
287
+
288
+ if (response.status === 307 && response.headers.get('location')) {
289
+ const redirected = response.headers.get('location');
290
+ const nextBase = redirected.startsWith('http') ? redirected : new URL(redirected, baseUrl).href;
291
+ return verifyManifestExists(nextBase, tag, headers);
292
+ }
293
+
294
+ return response.status === 200;
295
+ }
296
+
284
297
  async function prepareUploadLocation(baseUrl, headers) {
285
298
  const url = new URL('blobs/uploads/', baseUrl);
286
299
  // Debug logging only - removed verbose output
@@ -497,11 +510,16 @@ async function uploadDockerImage({
497
510
  }) {
498
511
  const baseUrl = `${registryUrl}${uniqueName}/`;
499
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
500
514
  const headers = {
501
515
  'x-ks-clientid': cid,
502
516
  'x-ks-projectid': pid, // Use realm PID (not gamePid) - matches ctx.Pid in C# CLI
503
517
  'x-ks-token': token, // Access token from login
504
518
  };
519
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
520
+ console.error(`[beamo-node] Uploading to: ${baseUrl}`);
521
+ console.error(`[beamo-node] Upload headers PID: ${pid} (realm), gamePid: ${gamePid}`);
522
+ }
505
523
 
506
524
  const { manifestEntry, configBuffer, layers } = await readDockerImageTar(imageTarPath);
507
525
 
@@ -834,6 +852,12 @@ async function updateManifest({
834
852
  storageReferences,
835
853
  };
836
854
 
855
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
856
+ console.error(`[beamo-node] Publishing manifest with imageId: ${shortImageId}`);
857
+ console.error(`[beamo-node] Service: ${serviceId}, CID: ${cid}, PID: ${pid}`);
858
+ console.error(`[beamo-node] Manifest service entry:`, JSON.stringify(mappedServices.find(s => s.serviceName === serviceId), null, 2));
859
+ }
860
+
837
861
  const response = await fetch(new URL('/api/beamo/manifests', apiHost), {
838
862
  method: 'POST',
839
863
  headers: {
@@ -847,6 +871,11 @@ async function updateManifest({
847
871
 
848
872
  if (!response.ok) {
849
873
  const text = await response.text();
874
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
875
+ console.error(`[beamo-node] Manifest publish failed: ${response.status}`);
876
+ console.error(`[beamo-node] Response: ${text}`);
877
+ console.error(`[beamo-node] Request body:`, JSON.stringify(requestBody, null, 2));
878
+ }
850
879
  throw new Error(`Failed to publish manifest: ${response.status} ${text}`);
851
880
  }
852
881
  }
@@ -1064,6 +1093,11 @@ async function main() {
1064
1093
 
1065
1094
  const registryUrl = await getRegistryUrl(apiHost, token, cid, resolvedGamePid);
1066
1095
  const uniqueName = md5Hex(`${cid}_${resolvedGamePid}_${serviceId}`).substring(0, 30);
1096
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
1097
+ console.error(`[beamo-node] Registry URL: ${registryUrl}`);
1098
+ console.error(`[beamo-node] Unique name: ${uniqueName}`);
1099
+ console.error(`[beamo-node] CID: ${cid}, PID: ${pid}, Game PID: ${resolvedGamePid}`);
1100
+ }
1067
1101
  progress.complete('Authenticated');
1068
1102
 
1069
1103
  // Step 6: Upload Docker image
@@ -1083,11 +1117,36 @@ async function main() {
1083
1117
  });
1084
1118
  progress.complete('Image uploaded');
1085
1119
 
1120
+ // Verify image exists in registry before proceeding
1121
+ // Note: Backend might check using gamePid, so we verify using the same PID used for upload
1122
+ const shortImageIdForVerify = shortDigest(fullImageId);
1123
+ const baseUrl = `${registryUrl}${uniqueName}/`;
1124
+ const verifyHeaders = {
1125
+ 'x-ks-clientid': cid,
1126
+ 'x-ks-projectid': pid, // Use realm PID (matches upload headers)
1127
+ 'x-ks-token': token,
1128
+ };
1129
+
1130
+ // Wait a moment for registry to propagate, then verify
1131
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
1132
+ console.error(`[beamo-node] Verifying image exists: ${baseUrl}manifests/${shortImageIdForVerify}`);
1133
+ console.error(`[beamo-node] Using headers:`, { cid, pid, gamePid: resolvedGamePid });
1134
+ }
1135
+ await new Promise(resolve => setTimeout(resolve, 2000)); // Increased delay
1136
+ const imageExists = await verifyManifestExists(baseUrl, shortImageIdForVerify, verifyHeaders);
1137
+ if (!imageExists) {
1138
+ throw new Error(`Image verification failed: manifest with tag ${shortImageIdForVerify} not found in registry at ${baseUrl}manifests/${shortImageIdForVerify}. The image may not have uploaded successfully. Check that the registry path and tag match what the backend expects.`);
1139
+ }
1140
+ if (process.env.BEAMO_DEBUG === '1' || process.env.BEAMO_NODE_DEBUG === '1') {
1141
+ console.error(`[beamo-node] Image verification passed: ${baseUrl}manifests/${shortImageIdForVerify}`);
1142
+ }
1143
+
1086
1144
  // Step 7: Discover storage, components, and dependencies
1087
1145
  progress.start('Discovering storage objects and components');
1088
1146
  const shortImageId = shortDigest(fullImageId);
1089
- // Use full image ID (sha256:...) for backend manifest - backend needs full digest to verify image exists
1090
- // The shortImageId is still used for the registry tag, but backend manifest needs full digest
1147
+ // The backend looks up images using the short imageId tag (matches registry tag)
1148
+ // Add a small delay to ensure registry has propagated the image before backend checks
1149
+ await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay
1091
1150
  const existingManifest = await fetchCurrentManifest(apiHost, token, cid, pid);
1092
1151
  const discoveredStorage = await discoverStorageObjects('src');
1093
1152
  const discoveredComponents = await discoverFederationComponents('src');
@@ -1107,7 +1166,7 @@ async function main() {
1107
1166
  cid,
1108
1167
  pid,
1109
1168
  serviceId,
1110
- shortImageId: fullImageId, // Use full digest for backend verification
1169
+ shortImageId, // Use short hash - backend looks up by tag which matches registry tag
1111
1170
  comments: args.comments,
1112
1171
  existingManifest,
1113
1172
  discoveredStorage,