@podium/client 5.1.8 → 5.1.10-next.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [5.1.10-next.1](https://github.com/podium-lib/client/compare/v5.1.9...v5.1.10-next.1) (2024-08-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use AbortSignal to ensure timeouts are respected ([08899d9](https://github.com/podium-lib/client/commit/08899d974246037cb1893a5b6d06bd6df58815e2))
7
+
8
+ ## [5.1.9](https://github.com/podium-lib/client/compare/v5.1.8...v5.1.9) (2024-08-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency undici to v6.19.8 ([bd00ad4](https://github.com/podium-lib/client/commit/bd00ad41f452f7ddd40518bfc93f23eb812704d4))
14
+
1
15
  ## [5.1.8](https://github.com/podium-lib/client/compare/v5.1.7...v5.1.8) (2024-08-19)
2
16
 
3
17
 
package/lib/http.js CHANGED
@@ -1,4 +1,4 @@
1
- import { request } from 'undici';
1
+ import { request as undiciRequest } from 'undici';
2
2
 
3
3
  /**
4
4
  * @typedef {object} PodiumHttpClientRequestOptions
@@ -7,21 +7,27 @@ import { request } from 'undici';
7
7
  * @property {boolean} [rejectUnauthorized]
8
8
  * @property {boolean} [follow]
9
9
  * @property {number} [timeout]
10
- * @property {number} [bodyTimeout]
11
10
  * @property {object} [query]
12
11
  * @property {import('http').IncomingHttpHeaders} [headers]
13
12
  */
14
13
 
15
14
  export default class HTTP {
15
+ constructor(requestFn = undiciRequest) {
16
+ this.requestFn = requestFn;
17
+ }
18
+
16
19
  /**
17
20
  * @param {string} url
18
21
  * @param {PodiumHttpClientRequestOptions} options
19
22
  * @returns {Promise<Pick<import('undici').Dispatcher.ResponseData, 'statusCode' | 'headers' | 'body'>>}
20
23
  */
21
24
  async request(url, options) {
22
- const { statusCode, headers, body } = await request(
25
+ const { statusCode, headers, body } = await this.requestFn(
23
26
  new URL(url),
24
- options,
27
+ {
28
+ ...options,
29
+ signal: AbortSignal.timeout(options.timeout || 1000),
30
+ },
25
31
  );
26
32
  return { statusCode, headers, body };
27
33
  }
@@ -136,7 +136,7 @@ export default class PodletClientContentResolver {
136
136
  /** @type {import('./http.js').PodiumHttpClientRequestOptions} */
137
137
  const reqOptions = {
138
138
  rejectUnauthorized: outgoing.rejectUnauthorized,
139
- bodyTimeout: outgoing.timeout,
139
+ timeout: outgoing.timeout,
140
140
  method: 'GET',
141
141
  query: outgoing.reqOptions.query,
142
142
  headers,
@@ -267,6 +267,7 @@ export default class PodletClientContentResolver {
267
267
  }),
268
268
  );
269
269
 
270
+ // @ts-ignore
270
271
  pipeline([body, outgoing], (err) => {
271
272
  if (err) {
272
273
  this.#log.warn('error while piping content stream', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podium/client",
3
- "version": "5.1.8",
3
+ "version": "5.1.10-next.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -45,7 +45,7 @@
45
45
  "http-cache-semantics": "^4.0.3",
46
46
  "lodash.clonedeep": "^4.5.0",
47
47
  "ttl-mem-cache": "4.1.0",
48
- "undici": "6.19.7"
48
+ "undici": "6.19.8"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@podium/test-utils": "2.5.2",
package/types/http.d.ts CHANGED
@@ -5,11 +5,12 @@
5
5
  * @property {boolean} [rejectUnauthorized]
6
6
  * @property {boolean} [follow]
7
7
  * @property {number} [timeout]
8
- * @property {number} [bodyTimeout]
9
8
  * @property {object} [query]
10
9
  * @property {import('http').IncomingHttpHeaders} [headers]
11
10
  */
12
11
  export default class HTTP {
12
+ constructor(requestFn?: typeof undiciRequest);
13
+ requestFn: typeof undiciRequest;
13
14
  /**
14
15
  * @param {string} url
15
16
  * @param {PodiumHttpClientRequestOptions} options
@@ -23,7 +24,7 @@ export type PodiumHttpClientRequestOptions = {
23
24
  rejectUnauthorized?: boolean;
24
25
  follow?: boolean;
25
26
  timeout?: number;
26
- bodyTimeout?: number;
27
27
  query?: object;
28
28
  headers?: import('http').IncomingHttpHeaders;
29
29
  };
30
+ import { request as undiciRequest } from 'undici';