@go-avro/avro-js 0.0.80 → 0.0.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.
@@ -54,7 +54,11 @@ AvroQueryClient.prototype._fetch = async function (method, path, body, cancelTok
54
54
  await this.config.authManager.refreshTokens();
55
55
  return this._fetch(method, path, body, cancelToken, headers, isIdempotent, 1);
56
56
  }
57
- if (response.status !== 401 && retryCount < this.config.maxRetries) {
57
+ const isClientError = response.status >= 400 &&
58
+ response.status < 500 &&
59
+ response.status !== 408 &&
60
+ response.status !== 429;
61
+ if (!isClientError && retryCount < this.config.maxRetries) {
58
62
  const delay = this.getDelay(this.config.retryStrategy, retryCount);
59
63
  await this.sleep(delay);
60
64
  return this._fetch(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1);
@@ -51,14 +51,16 @@ AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken
51
51
  }
52
52
  else {
53
53
  let msg = xhr.responseText || xhr.statusText;
54
+ let errorBody;
54
55
  try {
55
56
  const parsed = JSON.parse(xhr.responseText);
57
+ errorBody = parsed;
56
58
  msg = parsed.message ?? parsed.msg ?? msg;
57
59
  }
58
60
  catch (e) {
59
61
  console.error('Ignoring:', e);
60
62
  }
61
- reject(new StandardError(xhr.status, msg));
63
+ reject(new StandardError(xhr.status, msg, errorBody));
62
64
  }
63
65
  };
64
66
  xhr.onerror = () => reject(new StandardError(0, 'Network Error'));
@@ -103,7 +105,11 @@ AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken
103
105
  throw new StandardError(401, 'Unauthorized (refresh failed)');
104
106
  }
105
107
  }
106
- if (error.status === 401 || attempt >= maxRetries) {
108
+ const isClientError = error.status >= 400 &&
109
+ error.status < 500 &&
110
+ error.status !== 408 &&
111
+ error.status !== 429;
112
+ if (error.status === 401 || isClientError || attempt >= maxRetries) {
107
113
  console.error('Not retrying request, throwing error.');
108
114
  throw error;
109
115
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "0.0.80";
1
+ export declare const AVRO_JS_VERSION = "0.0.81";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '0.0.80';
3
+ export const AVRO_JS_VERSION = '0.0.81';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",