@blaxel/core 0.2.49-dev.213 → 0.2.49-dev.214

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.
@@ -10,7 +10,7 @@ function getPackageVersion() {
10
10
  if (typeof require !== "undefined") {
11
11
  // Try to require package.json (Node.js only, gracefully fails in browser)
12
12
  // eslint-disable-next-line @typescript-eslint/no-require-imports
13
- const packageJson = {"version":"0.2.49-dev.213","commit":"6b51b11f0b2030cfdcd965e446466b79a79707f5"};
13
+ const packageJson = {"version":"0.2.49-dev.214","commit":"3cd25c395e498b34304684d4d76a906f2cef14a9"};
14
14
  return packageJson.version || "unknown";
15
15
  }
16
16
  else {
@@ -62,7 +62,7 @@ function getCommitHash() {
62
62
  if (typeof require !== "undefined") {
63
63
  // Try to require package.json and look for commit field (set during build)
64
64
  // eslint-disable-next-line @typescript-eslint/no-require-imports
65
- const packageJson = {"version":"0.2.49-dev.213","commit":"6b51b11f0b2030cfdcd965e446466b79a79707f5"};
65
+ const packageJson = {"version":"0.2.49-dev.214","commit":"3cd25c395e498b34304684d4d76a906f2cef14a9"};
66
66
  // Check for commit in various possible locations
67
67
  const commit = packageJson.commit || packageJson.buildInfo?.commit;
68
68
  if (commit) {
@@ -5,12 +5,43 @@ const autoload_js_1 = require("../common/autoload.js");
5
5
  const env_js_1 = require("../common/env.js");
6
6
  const telemetry_js_1 = require("../telemetry/telemetry.js");
7
7
  class BlJobWrapper {
8
+ async fetchWithRetry(url, maxRetries = 3) {
9
+ let lastError;
10
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
11
+ try {
12
+ const response = await fetch(url);
13
+ // If the response is successful, return it
14
+ if (response.ok) {
15
+ return response;
16
+ }
17
+ // If it's not the last attempt and the status is retriable, retry
18
+ if (attempt < maxRetries && (response.status >= 500 || response.status === 429)) {
19
+ lastError = new Error(`HTTP ${response.status}: ${response.statusText}`);
20
+ }
21
+ else {
22
+ // For non-retriable errors or last attempt, return the response
23
+ return response;
24
+ }
25
+ }
26
+ catch (error) {
27
+ lastError = error instanceof Error ? error : new Error(String(error));
28
+ // If this is the last attempt, throw the error
29
+ if (attempt === maxRetries) {
30
+ throw lastError;
31
+ }
32
+ }
33
+ // Calculate exponential backoff delay: 2^attempt * 1000ms (1s, 2s, 4s)
34
+ const delay = Math.pow(2, attempt) * 1000;
35
+ await new Promise(resolve => setTimeout(resolve, delay));
36
+ }
37
+ throw lastError || new Error('Failed to fetch after retries');
38
+ }
8
39
  async getArguments() {
9
40
  if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
10
41
  const args = this.parseCommandLineArgs();
11
42
  return args;
12
43
  }
13
- const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
44
+ const response = await this.fetchWithRetry(env_js_1.env.BL_EXECUTION_DATA_URL);
14
45
  const data = await response.json();
15
46
  return data.tasks[this.index] ?? {};
16
47
  }