Socket
Socket
Sign inDemoInstall

@opensearch-project/opensearch

Package Overview
Dependencies
Maintainers
7
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opensearch-project/opensearch - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

3

index.js

@@ -181,3 +181,4 @@ /*

opaqueIdPrefix: options.opaqueIdPrefix,
context: options.context
context: options.context,
memoryCircuitBreaker: options.memoryCircuitBreaker
})

@@ -184,0 +185,0 @@

@@ -118,2 +118,3 @@ /*

}
operation: Action
document: TDocument

@@ -120,0 +121,0 @@ retried: boolean

@@ -54,2 +54,3 @@ /*

const MAX_STRING_LENGTH = buffer.constants.MAX_STRING_LENGTH
const HEAP_SIZE_LIMIT = require('v8').getHeapStatistics().heap_size_limit
const kCompatibleCheck = Symbol('compatible check')

@@ -85,2 +86,3 @@ const kApiVersioning = Symbol('api versioning')

this[kApiVersioning] = process.env.OPENSEARCH_CLIENT_APIVERSIONING === 'true'
this.memoryCircuitBreaker = opts.memoryCircuitBreaker

@@ -252,6 +254,6 @@ this.nodeFilter = opts.nodeFilter || defaultNodeFilter

const isCompressed = contentEncoding.indexOf('gzip') > -1 || contentEncoding.indexOf('deflate') > -1
/* istanbul ignore else */
if (result.headers['content-length'] !== undefined) {
const contentLength = Number(result.headers['content-length'])
// nodeJS data type limit check
if (isCompressed && contentLength > MAX_BUFFER_LENGTH) {

@@ -267,2 +269,8 @@ response.destroy()

)
} else if (shouldApplyCircuitBreaker(contentLength)) {
// Abort this response to avoid OOM crash of dashboards.
response.destroy()
return onConnectionError(
new RequestAbortedError(`The content length (${contentLength}) is bigger than the maximum allowed heap memory limit.`, result)
)
}

@@ -308,2 +316,9 @@ }

}
// Helper function to check if memory circuit breaker enabled and the response payload is too large to fit into available heap memory.
const shouldApplyCircuitBreaker = (contentLength) => {
if (!this.memoryCircuitBreaker || !this.memoryCircuitBreaker.enabled) return false
const maxPercentage = validateMemoryPercentage(this.memoryCircuitBreaker.maxPercentage)
const heapUsed = process.memoryUsage().heapUsed
return contentLength + heapUsed > HEAP_SIZE_LIMIT * maxPercentage
}

@@ -644,2 +659,7 @@ const onBody = (err, payload) => {

function validateMemoryPercentage (percentage) {
if (percentage < 0 || percentage > 1) return 1.0
return percentage
}
module.exports = Transport

@@ -646,0 +666,0 @@ module.exports.internals = {

@@ -14,3 +14,3 @@ {

"homepage": "https://www.opensearch.org/",
"version": "1.0.2",
"version": "1.1.0",
"versionCanary": "7.10.0-canary.6",

@@ -17,0 +17,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc