@opensearch-project/opensearch 2.12.0 → 2.14.0
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 +15 -0
- package/RELEASING.md +4 -5
- package/lib/Serializer.js +1 -1
- package/lib/Transport.js +48 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,21 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
|
11
11
|
### Fixed
|
|
12
12
|
### Security
|
|
13
13
|
|
|
14
|
+
## [2.14.0]
|
|
15
|
+
### Changed
|
|
16
|
+
- Publish 2.x releases through the npm trusted publisher workflow under the `latest-2.x` dist-tag ([#1175](https://github.com/opensearch-project/opensearch-js/pull/1175))
|
|
17
|
+
### Fixed
|
|
18
|
+
- Apply the response size limits even when the response has no `Content-Length` header, and cap the size of a decompressed response body ([#1166](https://github.com/opensearch-project/opensearch-js/pull/1166))
|
|
19
|
+
|
|
20
|
+
## [2.13.0]
|
|
21
|
+
### Dependencies
|
|
22
|
+
- Bumps `micromatch` from 4.0.7 to 4.0.8
|
|
23
|
+
- Bumps `simple-statistics` from 7.8.4 to 7.8.5
|
|
24
|
+
- Bumps `simple-git` from 3.25.0 to 3.26.0
|
|
25
|
+
- Bumps `@types/node` from 22.5.0 to 22.5.2
|
|
26
|
+
### Fixed
|
|
27
|
+
- Upgrade `JSON11` from 1.1.2 to 2.0.0 to ensure UTF-8 safety when stringifying JSON data
|
|
28
|
+
|
|
14
29
|
## [2.12.0]
|
|
15
30
|
### Dependencies
|
|
16
31
|
- Bumps `@babel/eslint-parser` from 7.24.8 to 7.25.1
|
package/RELEASING.md
CHANGED
|
@@ -33,9 +33,8 @@ Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v
|
|
|
33
33
|
|
|
34
34
|
The release process is standard across repositories in this org and is run by a release manager volunteering from amongst [maintainers](MAINTAINERS.md).
|
|
35
35
|
|
|
36
|
-
1. Create a tag, e.g.
|
|
37
|
-
1. The [release-drafter.yml](.github/workflows/release-drafter.yml) will be automatically kicked off and is responsible for
|
|
38
|
-
1.
|
|
39
|
-
1.
|
|
40
|
-
1. Once the above release workflow is successful, the drafted release on GitHub is published automatically.
|
|
36
|
+
1. Create a tag, e.g. 2.14.0, and push it to the GitHub repo.
|
|
37
|
+
1. The [release-drafter.yml](.github/workflows/release-drafter.yml) will be automatically kicked off and is responsible for publishing the package to NPM and creating a release on GitHub.
|
|
38
|
+
1. The workflow requires approval from reviewers configured in the `release-approval` GitHub environment before it proceeds.
|
|
39
|
+
1. Once approved, the workflow publishes to NPM using trusted publishers (OIDC authentication) under the `latest-2.x` dist-tag, so `latest` stays on 3.x. It then creates a GitHub release with auto-generated release notes, without marking it as the latest release.
|
|
41
40
|
1. Increment "version" in package.json to the next patch release, e.g. v2.1.1. See [example](https://github.com/opensearch-project/opensearch-js/pull/318)
|
package/lib/Serializer.js
CHANGED
|
@@ -101,7 +101,7 @@ class Serializer {
|
|
|
101
101
|
if (
|
|
102
102
|
numeralsAreNumbers &&
|
|
103
103
|
typeof val === 'number' &&
|
|
104
|
-
(val < Number.
|
|
104
|
+
(val < Number.MIN_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER)
|
|
105
105
|
) {
|
|
106
106
|
numeralsAreNumbers = false;
|
|
107
107
|
}
|
package/lib/Transport.js
CHANGED
|
@@ -318,11 +318,35 @@ class Transport {
|
|
|
318
318
|
// if the response is compressed, we must handle it
|
|
319
319
|
// as buffer for allowing decompression later
|
|
320
320
|
let payload = isCompressed ? [] : '';
|
|
321
|
+
// Bound the body as it arrives; content-length is absent on chunked responses.
|
|
322
|
+
let received = 0;
|
|
323
|
+
const decodedLimit = maxDecodedLength();
|
|
321
324
|
const onData = isCompressed
|
|
322
325
|
? (chunk) => {
|
|
326
|
+
received += chunk.length;
|
|
327
|
+
/* istanbul ignore next: needs a >2 GiB compressed body */
|
|
328
|
+
if (received > MAX_BUFFER_LENGTH) {
|
|
329
|
+
response.destroy();
|
|
330
|
+
return onEnd(
|
|
331
|
+
new RequestAbortedError(
|
|
332
|
+
`The response body size is bigger than the maximum allowed buffer (${MAX_BUFFER_LENGTH})`,
|
|
333
|
+
result
|
|
334
|
+
)
|
|
335
|
+
);
|
|
336
|
+
}
|
|
323
337
|
payload.push(chunk);
|
|
324
338
|
}
|
|
325
339
|
: (chunk) => {
|
|
340
|
+
received += chunk.length;
|
|
341
|
+
if (received > decodedLimit) {
|
|
342
|
+
response.destroy();
|
|
343
|
+
return onEnd(
|
|
344
|
+
new RequestAbortedError(
|
|
345
|
+
`The response body size is bigger than the maximum allowed size (${decodedLimit})`,
|
|
346
|
+
result
|
|
347
|
+
)
|
|
348
|
+
);
|
|
349
|
+
}
|
|
326
350
|
payload += chunk;
|
|
327
351
|
};
|
|
328
352
|
const onEnd = (err) => {
|
|
@@ -332,11 +356,15 @@ class Transport {
|
|
|
332
356
|
response.removeListener('aborted', onAbort);
|
|
333
357
|
|
|
334
358
|
if (err) {
|
|
335
|
-
|
|
359
|
+
// A size-limit abort must not be retried; a connection error may be.
|
|
360
|
+
return onConnectionError(
|
|
361
|
+
err instanceof RequestAbortedError ? err : new ConnectionError(err.message)
|
|
362
|
+
);
|
|
336
363
|
}
|
|
337
364
|
|
|
338
365
|
if (isCompressed) {
|
|
339
|
-
|
|
366
|
+
// maxOutputLength caps the decoded size; overflow returns an error, not a throw.
|
|
367
|
+
unzip(Buffer.concat(payload), { maxOutputLength: decodedLimit }, onBody);
|
|
340
368
|
} else {
|
|
341
369
|
onBody(null, payload);
|
|
342
370
|
}
|
|
@@ -365,13 +393,30 @@ class Transport {
|
|
|
365
393
|
return contentLength + heapUsed > HEAP_SIZE_LIMIT * maxPercentage;
|
|
366
394
|
};
|
|
367
395
|
|
|
396
|
+
const maxDecodedLength = () => {
|
|
397
|
+
let limit = MAX_STRING_LENGTH;
|
|
398
|
+
if (this.memoryCircuitBreaker && this.memoryCircuitBreaker.enabled) {
|
|
399
|
+
const maxPercentage = validateMemoryPercentage(this.memoryCircuitBreaker.maxPercentage);
|
|
400
|
+
const heapUsed = process.memoryUsage().heapUsed;
|
|
401
|
+
const heapBudget = Math.floor(HEAP_SIZE_LIMIT * maxPercentage - heapUsed);
|
|
402
|
+
limit = Math.min(limit, Math.max(1, heapBudget));
|
|
403
|
+
}
|
|
404
|
+
return limit;
|
|
405
|
+
};
|
|
406
|
+
|
|
368
407
|
const onBody = (err, payload) => {
|
|
369
408
|
if (err) {
|
|
370
409
|
this.emit('response', err, result);
|
|
371
410
|
return callback(err, result);
|
|
372
411
|
}
|
|
373
412
|
if (Buffer.isBuffer(payload)) {
|
|
374
|
-
|
|
413
|
+
/* istanbul ignore next: unreachable once the output is capped below the max string length */
|
|
414
|
+
try {
|
|
415
|
+
payload = payload.toString();
|
|
416
|
+
} catch (err) {
|
|
417
|
+
this.emit('response', err, result);
|
|
418
|
+
return callback(err, result);
|
|
419
|
+
}
|
|
375
420
|
}
|
|
376
421
|
const isHead = params.method === 'HEAD';
|
|
377
422
|
// we should attempt the payload deserialization only if:
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://www.opensearch.org/",
|
|
36
|
-
"version": "2.
|
|
36
|
+
"version": "2.14.0",
|
|
37
37
|
"versionCanary": "7.10.0-canary.6",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"opensearch",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"dependencies": {
|
|
105
105
|
"aws4": "^1.11.0",
|
|
106
106
|
"debug": "^4.3.1",
|
|
107
|
-
"json11": "^
|
|
107
|
+
"json11": "^2.0.0",
|
|
108
108
|
"hpagent": "^1.2.0",
|
|
109
109
|
"ms": "^2.1.3",
|
|
110
110
|
"secure-json-parse": "^2.4.0"
|