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