apify-client 3.0.0-beta.72 → 3.0.0-beta.73

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.
@@ -280,7 +280,8 @@ export declare abstract class HttpClient {
280
280
  * The inherited {@link call} needs it, so every transport has to implement it. Let the library's errors
281
281
  * propagate unwrapped: {@link call} classifies them through {@link isRetryableTransportError} and
282
282
  * {@link isTimeoutError}. Return error responses as they are too, the pipeline turns them into
283
- * {@link ApifyApiError} and decides whether to retry.
283
+ * {@link ApifyApiError} and decides whether to retry. Reject when the connection drops before the body is
284
+ * complete: the pipeline takes a returned body as whole and does not retry one that fails to parse.
284
285
  *
285
286
  * @param request - The request to send, with the headers merged, the body serialized and the query encoded.
286
287
  * @returns The response, with the body unread when `request.stream` is set and as raw bytes otherwise.
@@ -169,7 +169,8 @@ export class HttpClient {
169
169
  * The inherited {@link call} needs it, so every transport has to implement it. Let the library's errors
170
170
  * propagate unwrapped: {@link call} classifies them through {@link isRetryableTransportError} and
171
171
  * {@link isTimeoutError}. Return error responses as they are too, the pipeline turns them into
172
- * {@link ApifyApiError} and decides whether to retry.
172
+ * {@link ApifyApiError} and decides whether to retry. Reject when the connection drops before the body is
173
+ * complete: the pipeline takes a returned body as whole and does not retry one that fails to parse.
173
174
  *
174
175
  * @param request - The request to send, with the headers merged, the body serialized and the query encoded.
175
176
  * @returns The response, with the body unread when `request.stream` is set and as raw bytes otherwise.
@@ -357,12 +358,14 @@ export class HttpClient {
357
358
  data = this.#parseResponseBody(response, config);
358
359
  }
359
360
  catch (err) {
360
- // A body that does not parse is usually a connection dropped mid-response, which a retry fixes.
361
- if (requestIsStream) {
362
- this.#informAboutStreamNoRetry();
361
+ // The body of a success arrived in full, since a transfer cut short fails in `sendRequest()`, so a
362
+ // retry would get the same body back.
363
+ if (response.status < 300) {
363
364
  stopRetrying();
365
+ throw err;
364
366
  }
365
- throw err;
367
+ // An error status is reported by its code, and `ApifyApiError` makes what it can of the raw body.
368
+ data = response.body;
366
369
  }
367
370
  const apifyResponse = {
368
371
  status: response.status,
@@ -1,9 +1,9 @@
1
1
  import { ApifyClientError } from './apify_client_error.js';
2
2
  import type { HttpResponse } from './http_clients/base.js';
3
3
  /**
4
- * Thrown when a response body does not parse as its content type claims, typically a JSON document cut short by a
5
- * connection dropped mid-response. The client retries such requests, so the error surfaces once the retries are
6
- * exhausted.
4
+ * Thrown when the body of a successful response does not parse as its content type claims, for example a non-JSON
5
+ * value stored under `application/json`. The response arrived in full, so the request is not retried. An error
6
+ * status with an unparsable body throws {@link ApifyApiError} for its status code.
7
7
  */
8
8
  export declare class InvalidResponseBodyError extends ApifyClientError {
9
9
  code: string;
@@ -1,8 +1,8 @@
1
1
  import { ApifyClientError } from './apify_client_error.js';
2
2
  /**
3
- * Thrown when a response body does not parse as its content type claims, typically a JSON document cut short by a
4
- * connection dropped mid-response. The client retries such requests, so the error surfaces once the retries are
5
- * exhausted.
3
+ * Thrown when the body of a successful response does not parse as its content type claims, for example a non-JSON
4
+ * value stored under `application/json`. The response arrived in full, so the request is not retried. An error
5
+ * status with an unparsable body throws {@link ApifyApiError} for its status code.
6
6
  */
7
7
  export class InvalidResponseBodyError extends ApifyClientError {
8
8
  code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-client",
3
- "version": "3.0.0-beta.72",
3
+ "version": "3.0.0-beta.73",
4
4
  "description": "Apify API client for JavaScript",
5
5
  "engines": {
6
6
  "node": ">=22.13.0"