catalyst-relay 0.5.12 → 0.5.13

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/dist/index.js CHANGED
@@ -1614,7 +1614,9 @@ async function updateObject(client, object, lockHandle, transport) {
1614
1614
 
1615
1615
  // src/core/adt/craud/activation.ts
1616
1616
  var MAX_POLL_ATTEMPTS = 30;
1617
+ var POLL_RETRY_DELAY_MS = 1e3;
1617
1618
  var RUN_ID_REGEX = /\/activation\/runs\/([^?/]+)/;
1619
+ var BACKGROUND_RUN_MEDIA_TYPE = "application/vnd.sap.adt.backgroundrun.v1+xml";
1618
1620
  async function activateObjects(client, objects) {
1619
1621
  if (objects.length === 0) {
1620
1622
  return ok([]);
@@ -1640,7 +1642,7 @@ async function activateObjects(client, objects) {
1640
1642
  },
1641
1643
  headers: {
1642
1644
  "Content-Type": "application/xml",
1643
- "Accept": "application/xml"
1645
+ "Accept": BACKGROUND_RUN_MEDIA_TYPE
1644
1646
  },
1645
1647
  body
1646
1648
  });
@@ -1658,22 +1660,25 @@ async function activateObjects(client, objects) {
1658
1660
  }
1659
1661
  const runId = runIdMatch[1];
1660
1662
  debug(`Activation run ID: ${runId}`);
1661
- let pollAttempt = 0;
1662
- while (pollAttempt < MAX_POLL_ATTEMPTS) {
1663
+ for (let pollAttempt = 1; pollAttempt <= MAX_POLL_ATTEMPTS; pollAttempt++) {
1663
1664
  const [pollRes, pollErr] = await client.request({
1664
1665
  method: "GET",
1665
1666
  path: `/sap/bc/adt/activation/runs/${runId}`,
1666
1667
  params: { "withLongPolling": "true" },
1667
- headers: { "Accept": "application/xml" }
1668
+ headers: { "Accept": BACKGROUND_RUN_MEDIA_TYPE }
1668
1669
  });
1669
1670
  if (pollErr) return err(pollErr);
1670
- debug(`Activation poll attempt ${pollAttempt + 1} status: ${pollRes.status}`);
1671
+ debug(`Activation poll attempt ${pollAttempt} status: ${pollRes.status}`);
1671
1672
  if (pollRes.ok) break;
1672
- pollAttempt++;
1673
+ if (pollRes.status >= 400 && pollRes.status < 500) {
1674
+ const errText = await pollRes.text();
1675
+ return err(new Error(`Activation run ${runId} polling rejected (${pollRes.status}): ${extractError(errText)}`));
1676
+ }
1673
1677
  if (pollAttempt >= MAX_POLL_ATTEMPTS) {
1674
1678
  const errText = await pollRes.text();
1675
- return err(new Error(`Activation run ${runId} did not complete: ${extractError(errText)}`));
1679
+ return err(new Error(`Activation run ${runId} did not complete after ${MAX_POLL_ATTEMPTS} attempts: ${extractError(errText)}`));
1676
1680
  }
1681
+ await new Promise((resolve) => setTimeout(resolve, POLL_RETRY_DELAY_MS));
1677
1682
  }
1678
1683
  const [resultsRes, resultsErr] = await client.request({
1679
1684
  method: "GET",