@elastic/elasticsearch-canary
Advanced tools
Comparing version 7.16.0-canary.2 to 7.16.0-canary.3
17
index.js
@@ -24,2 +24,3 @@ /* | ||
const { URL } = require('url') | ||
const buffer = require('buffer') | ||
const debug = require('debug')('elasticsearch') | ||
@@ -118,5 +119,15 @@ const Transport = require('./lib/Transport') | ||
enableMetaHeader: true, | ||
disablePrototypePoisoningProtection: false | ||
disablePrototypePoisoningProtection: false, | ||
maxResponseSize: null, | ||
maxCompressedResponseSize: null | ||
}, opts) | ||
if (options.maxResponseSize !== null && options.maxResponseSize > buffer.constants.MAX_STRING_LENGTH) { | ||
throw new ConfigurationError(`The maxResponseSize cannot be bigger than ${buffer.constants.MAX_STRING_LENGTH}`) | ||
} | ||
if (options.maxCompressedResponseSize !== null && options.maxCompressedResponseSize > buffer.constants.MAX_LENGTH) { | ||
throw new ConfigurationError(`The maxCompressedResponseSize cannot be bigger than ${buffer.constants.MAX_LENGTH}`) | ||
} | ||
if (options.caFingerprint !== null && isHttpConnection(opts.node || opts.nodes)) { | ||
@@ -183,3 +194,5 @@ throw new ConfigurationError('You can\'t configure the caFingerprint with a http connection') | ||
opaqueIdPrefix: options.opaqueIdPrefix, | ||
context: options.context | ||
context: options.context, | ||
maxResponseSize: options.maxResponseSize, | ||
maxCompressedResponseSize: options.maxCompressedResponseSize | ||
}) | ||
@@ -186,0 +199,0 @@ |
@@ -64,2 +64,4 @@ /* | ||
opaqueIdPrefix?: string; | ||
maxResponseSize?: number; | ||
maxCompressedResponseSize?: number; | ||
} | ||
@@ -117,2 +119,4 @@ | ||
opaqueId?: string; | ||
maxResponseSize?: number; | ||
maxCompressedResponseSize?: number; | ||
} | ||
@@ -119,0 +123,0 @@ |
@@ -46,2 +46,4 @@ /* | ||
const kEventEmitter = Symbol('event emitter') | ||
const kMaxResponseSize = Symbol('max response size') | ||
const kMaxCompressedResponseSize = Symbol('max compressed response size') | ||
@@ -76,2 +78,4 @@ class Transport { | ||
this[kEventEmitter] = new EventEmitter() | ||
this[kMaxResponseSize] = opts.maxResponseSize || MAX_STRING_LENGTH | ||
this[kMaxCompressedResponseSize] = opts.maxCompressedResponseSize || MAX_BUFFER_LENGTH | ||
@@ -167,2 +171,4 @@ this.nodeFilter = opts.nodeFilter || defaultNodeFilter | ||
const compression = options.compression !== undefined ? options.compression : this.compression | ||
const maxResponseSize = options.maxResponseSize || this[kMaxResponseSize] | ||
const maxCompressedResponseSize = options.maxCompressedResponseSize || this[kMaxCompressedResponseSize] | ||
let request = { abort: noop } | ||
@@ -250,11 +256,11 @@ const transportReturn = { | ||
const contentLength = Number(result.headers['content-length']) | ||
if (isCompressed && contentLength > MAX_BUFFER_LENGTH) { | ||
if (isCompressed && contentLength > maxCompressedResponseSize) { | ||
response.destroy() | ||
return onConnectionError( | ||
new RequestAbortedError(`The content length (${contentLength}) is bigger than the maximum allowed buffer (${MAX_BUFFER_LENGTH})`, result) | ||
new RequestAbortedError(`The content length (${contentLength}) is bigger than the maximum allowed buffer (${maxCompressedResponseSize})`, result) | ||
) | ||
} else if (contentLength > MAX_STRING_LENGTH) { | ||
} else if (contentLength > maxResponseSize) { | ||
response.destroy() | ||
return onConnectionError( | ||
new RequestAbortedError(`The content length (${contentLength}) is bigger than the maximum allowed string (${MAX_STRING_LENGTH})`, result) | ||
new RequestAbortedError(`The content length (${contentLength}) is bigger than the maximum allowed string (${maxResponseSize})`, result) | ||
) | ||
@@ -261,0 +267,0 @@ } |
@@ -14,4 +14,4 @@ { | ||
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", | ||
"version": "7.16.0-canary.2", | ||
"versionCanary": "7.16.0-canary.2", | ||
"version": "7.16.0-canary.3", | ||
"versionCanary": "7.16.0-canary.3", | ||
"keywords": [ | ||
@@ -107,3 +107,3 @@ "elasticsearch", | ||
}, | ||
"commitHash": "bb8f3977" | ||
"commitHash": "34a168dd" | ||
} |
@@ -31,3 +31,3 @@ <img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png"> | ||
NOTE: The minimum supported version of Node.js is `v10`. | ||
NOTE: The minimum supported version of Node.js is `v12`. | ||
@@ -53,9 +53,9 @@ The client versioning follows the Elastc Stack versioning, this means that | ||
| --------------- |------------------| ---------------------- | | ||
| `8.x` | `December 2019` | `7.11` (early 2021) | | ||
| `10.x` | `Apri 2021` | `7.12` (mid 2021) | | ||
| `8.x` | `December 2019` | `7.11` (early 2021) | | ||
| `10.x` | `April 2021` | `7.12` (mid 2021) | | ||
### Compatibility | ||
Language clients are forward compatible; meaning that clients support communicating with greater minor versions of Elasticsearch. | ||
Elastic language clients are also backwards compatible with lesser supported minor Elasticsearch versions. | ||
Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. | ||
Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made. | ||
@@ -62,0 +62,0 @@ | Elasticsearch Version | Client Version | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2225013
36331
105