@hiveio/dhive 1.3.3 → 1.3.5

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/lib/index.d.ts CHANGED
@@ -34,8 +34,7 @@
34
34
  */
35
35
  import * as utils from './utils';
36
36
  export { utils };
37
- export { NodeHealthTracker } from './health-tracker';
38
- export type { HealthTrackerOptions } from './health-tracker';
37
+ export { NodeHealthTracker, HealthTrackerOptions } from './health-tracker';
39
38
  export * from './helpers/blockchain';
40
39
  export * from './helpers/database';
41
40
  export * from './helpers/rc';
package/lib/utils.js CHANGED
@@ -187,21 +187,24 @@ function retryingFetch(currentAddress, allAddresses, opts, timeout, failoverThre
187
187
  }
188
188
  const response = yield cross_fetch_1.default(node, opts);
189
189
  if (!response.ok) {
190
- // Support for Drone: HTTP 500 with valid JSON-RPC response
191
- if (response.status === 500) {
192
- try {
193
- const resJson = yield response.json();
194
- if (resJson.jsonrpc === '2.0') {
195
- if (healthTracker && api)
196
- healthTracker.recordSuccess(node, api);
197
- return { response: resJson, currentAddress: node };
198
- }
199
- }
200
- catch (_b) {
201
- // JSON parse failed, fall through to error handling
190
+ // Some Hive nodes return non-200 HTTP status (500, 502, 503, 429, etc.)
191
+ // but still include a valid JSON-RPC response in the body.
192
+ // This happens when a node is overloaded — it processes the transaction
193
+ // but returns an error HTTP status. For broadcasts, ignoring the body
194
+ // would cause the caller to think it failed, leading to double-posts.
195
+ try {
196
+ const resJson = yield response.json();
197
+ if (resJson.jsonrpc === '2.0') {
198
+ if (healthTracker && api)
199
+ healthTracker.recordSuccess(node, api);
200
+ return { response: resJson, currentAddress: node };
202
201
  }
203
202
  }
204
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
203
+ catch (_b) {
204
+ // JSON parse failed, fall through to error handling
205
+ }
206
+ const statusText = response.statusText || `status code ${response.status}`;
207
+ throw new Error(`HTTP ${response.status}: ${statusText}`);
205
208
  }
206
209
  const responseJson = yield response.json();
207
210
  // Record success in health tracker
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.3.3';
3
+ exports.default = '1.3.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiveio/dhive",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Hive blockchain RPC client library",
5
5
  "author": "hive-network",
6
6
  "license": "BSD-3-Clause-No-Military-License",