@ezs/basics 1.23.2 → 1.23.3

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
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.23.3](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.2...@ezs/basics@1.23.3) (2023-02-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * 🐛 fetch timeout vs feed timeout ([163e0bf](https://github.com/Inist-CNRS/ezs/commit/163e0bf81df5f3d8ef7d2fedc6b8bf95ec2c8534))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [1.23.2](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.1...@ezs/basics@1.23.2) (2023-02-17)
7
18
 
8
19
 
@@ -7,6 +7,8 @@ exports.default = URLConnect;
7
7
 
8
8
  var _JSONStream = _interopRequireDefault(require("JSONStream"));
9
9
 
10
+ var _from = _interopRequireDefault(require("from"));
11
+
10
12
  var _debug = _interopRequireDefault(require("debug"));
11
13
 
12
14
  var _streamWrite = _interopRequireDefault(require("stream-write"));
@@ -70,6 +72,7 @@ async function URLConnect(data, feed) {
70
72
  }
71
73
 
72
74
  const parameters = {
75
+ timeout,
73
76
  method: 'POST',
74
77
  body: bodyIn,
75
78
  headers
@@ -82,10 +85,6 @@ async function URLConnect(data, feed) {
82
85
  }
83
86
 
84
87
  const controller = new _nodeAbortController.default();
85
- const timeoutHandle = setTimeout(() => {
86
- (0, _debug.default)('ezs')(`The maximum time allowed to start sending data has been reached (${timeout} msec).`);
87
- controller.abort();
88
- }, timeout);
89
88
  const response = await (0, _fetchWithProxy.default)(url, { ...parameters,
90
89
  signal: controller.signal
91
90
  });
@@ -99,30 +98,15 @@ async function URLConnect(data, feed) {
99
98
 
100
99
  if (retries === 1) {
101
100
  const bodyOut = json ? response.body.pipe(_JSONStream.default.parse('*')) : response.body;
102
- bodyOut.once('data', () => {
103
- clearTimeout(timeoutHandle);
104
- });
105
101
  bodyOut.once('error', e => {
102
+ controller.abort();
106
103
  output.emit('error', e);
107
- clearTimeout(timeoutHandle);
108
104
  });
109
105
  bodyOut.pipe(output);
110
106
  } else {
111
107
  const bodyOutRaw = await (0, _getStream.default)(response.body);
112
- clearTimeout(timeoutHandle);
113
-
114
- if (json) {
115
- try {
116
- const bodyOut = JSON.parse(bodyOutRaw);
117
- bodyOut.forEach(item => output.write(item));
118
- } catch (ee) {
119
- throw ee;
120
- }
121
- } else {
122
- output.write(bodyOutRaw);
123
- }
124
-
125
- output.end();
108
+ const bodyOutArray = JSON.parse(bodyOutRaw);
109
+ (0, _from.default)(bodyOutArray).pipe(output);
126
110
  }
127
111
  }, {
128
112
  retries
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ezs/basics",
3
3
  "description": "Basics statements for EZS",
4
- "version": "1.23.2",
4
+ "version": "1.23.3",
5
5
  "author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
6
6
  "bugs": "https://github.com/Inist-CNRS/ezs/issues",
7
7
  "dependencies": {
@@ -12,6 +12,7 @@
12
12
  "debug": "4.3.3",
13
13
  "fetch-with-proxy": "3.0.1",
14
14
  "flat": "5.0.2",
15
+ "from": "0.1.7",
15
16
  "get-stream": "6.0.1",
16
17
  "higher-path": "1.0.0",
17
18
  "lodash.escaperegexp": "4.1.2",
@@ -38,7 +39,7 @@
38
39
  "directories": {
39
40
  "test": "test"
40
41
  },
41
- "gitHead": "78a03050c3106e54a2a10c70ea67091b8b1ee711",
42
+ "gitHead": "a4926375389e3754d10cc958964b46b5d256214e",
42
43
  "homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
43
44
  "keywords": [
44
45
  "ezs"