Skip to content

Commit 6c2d4ac

Browse files
committed
Remove Node.js v8 support (#1402)
1 parent 496b2bb commit 6c2d4ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+247
-291
lines changed

.ci/test-matrix.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ NODE_JS_VERSION:
66
- 14
77
- 12
88
- 10
9-
- 8
109

1110
TEST_SUITE:
1211
- free

.github/workflows/nodejs.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,6 @@ jobs:
4040
run: |
4141
npm run test:types
4242
43-
test-node-v8:
44-
name: Test
45-
runs-on: ${{ matrix.os }}
46-
47-
strategy:
48-
matrix:
49-
node-version: [8.x]
50-
os: [ubuntu-latest, windows-latest, macOS-latest]
51-
52-
steps:
53-
- uses: actions/checkout@v2
54-
55-
- name: Use Node.js ${{ matrix.node-version }}
56-
uses: actions/setup-node@v1
57-
with:
58-
node-version: ${{ matrix.node-version }}
59-
60-
- name: Install
61-
run: |
62-
npm install
63-
64-
- name: Test
65-
run: |
66-
npm run test:node8
67-
6843
helpers-integration-test:
6944
name: Helpers integration test
7045
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ npm install @elastic/elasticsearch
2828

2929
### Node.js support
3030

31-
NOTE: The minimum supported version of Node.js is `v8`.
31+
NOTE: The minimum supported version of Node.js is `v10`.
3232

3333
The client versioning follows the Elastc Stack versioning, this means that
3434
major, minor, and patch releases are done following a precise schedule that

api/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ function handleError (err, callback) {
3131
}
3232

3333
function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring) {
34-
var target = {}
35-
var keys = Object.keys(querystring)
36-
for (var i = 0, len = keys.length; i < len; i++) {
37-
var key = keys[i]
34+
const target = {}
35+
const keys = Object.keys(querystring)
36+
for (let i = 0, len = keys.length; i < len; i++) {
37+
const key = keys[i]
3838
target[snakeCase[key] || key] = querystring[key]
3939
}
4040
return target

docs/examples/asStream.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ async function run () {
5757
})
5858
5959
// stream async iteration, available in Node.js ≥ 10
60-
var payload = ''
60+
let payload = ''
6161
body.setEncoding('utf8')
6262
for await (const chunk of body) {
6363
payload += chunk
6464
}
6565
console.log(JSON.parse(payload))
6666
6767
// classic stream callback style
68-
var payload = ''
68+
let payload = ''
6969
body.setEncoding('utf8')
7070
body.on('data', chunk => { payload += chunk })
7171
body.on('error', console.log)
@@ -101,4 +101,4 @@ fastify.post('/search/:index', async (req, reply) => {
101101
})
102102
103103
fastify.listen(3000)
104-
----
104+
----

docs/examples/scroll.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const client = new Client({ node: 'http://localhost:9200' })
124124
125125
// Scroll utility
126126
async function * scrollSearch (params) {
127-
var response = await client.search(params)
127+
let response = await client.search(params)
128128
129129
while (true) {
130130
const sourceHits = response.body.hits.hits
@@ -190,4 +190,4 @@ async function run () {
190190
}
191191
192192
run().catch(console.log)
193-
----
193+
----

docs/examples/sql.query.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function run () {
5151
5252
const data = body.rows.map(row => {
5353
const obj = {}
54-
for (var i = 0; i < row.length; i++) {
54+
for (let i = 0; i < row.length; i++) {
5555
obj[body.columns[i].name] = row[i]
5656
}
5757
return obj

docs/installation.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To learn more about the supported major versions, please refer to the
2424
[[nodejs-support]]
2525
=== Node.js support
2626

27-
NOTE: The minimum supported version of Node.js is `v8`.
27+
NOTE: The minimum supported version of Node.js is `v10`.
2828

2929
The client versioning follows the {stack} versioning, this means that
3030
major, minor, and patch releases are done following a precise schedule that

index.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const debug = require('debug')('elasticsearch')
2727
const Transport = require('./lib/Transport')
2828
const Connection = require('./lib/Connection')
2929
const { ConnectionPool, CloudConnectionPool } = require('./lib/pool')
30-
// Helpers works only in Node.js >= 10
31-
const Helpers = nodeMajor < 10 ? /* istanbul ignore next */ null : require('./lib/Helpers')
30+
const Helpers = require('./lib/Helpers')
3231
const Serializer = require('./lib/Serializer')
3332
const errors = require('./lib/errors')
3433
const { ConfigurationError } = errors
@@ -48,15 +47,6 @@ const kEventEmitter = Symbol('elasticsearchjs-event-emitter')
4847

4948
const ESAPI = require('./api')
5049

51-
/* istanbul ignore next */
52-
if (nodeMajor < 10) {
53-
process.emitWarning('You are using a version of Node.js that is currently in EOL. ' +
54-
'The support for this version will be dropped in 7.12. ' +
55-
'Please refer to https://ela.st/nodejs-support for additional information.',
56-
'DeprecationWarning'
57-
)
58-
}
59-
6050
/* istanbul ignore next */
6151
if (nodeMajor >= 10 && nodeMajor < 12) {
6252
process.emitWarning('You are using a version of Node.js that will reach EOL in April 2021. ' +
@@ -189,16 +179,13 @@ class Client extends ESAPI {
189179
context: options.context
190180
})
191181

192-
/* istanbul ignore else */
193-
if (Helpers !== null) {
194-
this.helpers = new Helpers({
195-
client: this,
196-
maxRetries: options.maxRetries,
197-
metaHeader: options.enableMetaHeader
198-
? `es=${clientVersion},js=${nodeVersion},t=${clientVersion},hc=${nodeVersion}`
199-
: null
200-
})
201-
}
182+
this.helpers = new Helpers({
183+
client: this,
184+
maxRetries: options.maxRetries,
185+
metaHeader: options.enableMetaHeader
186+
? `es=${clientVersion},js=${nodeVersion},t=${clientVersion},hc=${nodeVersion}`
187+
: null
188+
})
202189
}
203190

204191
get emit () {
@@ -223,7 +210,7 @@ class Client extends ESAPI {
223210
opts = {}
224211
}
225212

226-
var [namespace, method] = name.split('.')
213+
let [namespace, method] = name.split('.')
227214
if (method == null) {
228215
method = namespace
229216
namespace = null

lib/Connection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ class Connection {
213213
}
214214

215215
const paramsKeys = Object.keys(params)
216-
for (var i = 0, len = paramsKeys.length; i < len; i++) {
217-
var key = paramsKeys[i]
216+
for (let i = 0, len = paramsKeys.length; i < len; i++) {
217+
const key = paramsKeys[i]
218218
if (key === 'path') {
219219
request.pathname = resolve(request.pathname, params[key])
220220
} else if (key === 'querystring' && !!params[key] === true) {

lib/Serializer.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const { SerializationError, DeserializationError } = require('./errors')
2727
class Serializer {
2828
serialize (object) {
2929
debug('Serializing', object)
30+
let json
3031
try {
31-
var json = JSON.stringify(object)
32+
json = JSON.stringify(object)
3233
} catch (err) {
3334
throw new SerializationError(err.message, object)
3435
}
@@ -37,8 +38,9 @@ class Serializer {
3738

3839
deserialize (json) {
3940
debug('Deserializing', json)
41+
let object
4042
try {
41-
var object = sjson.parse(json)
43+
object = sjson.parse(json)
4244
} catch (err) {
4345
throw new DeserializationError(err.message, json)
4446
}
@@ -50,8 +52,8 @@ class Serializer {
5052
if (Array.isArray(array) === false) {
5153
throw new SerializationError('The argument provided is not an array')
5254
}
53-
var ndjson = ''
54-
for (var i = 0, len = array.length; i < len; i++) {
55+
let ndjson = ''
56+
for (let i = 0, len = array.length; i < len; i++) {
5557
if (typeof array[i] === 'string') {
5658
ndjson += array[i] + '\n'
5759
} else {
@@ -67,8 +69,8 @@ class Serializer {
6769
if (typeof object === 'string') return object
6870
// arrays should be serialized as comma separated list
6971
const keys = Object.keys(object)
70-
for (var i = 0, len = keys.length; i < len; i++) {
71-
var key = keys[i]
72+
for (let i = 0, len = keys.length; i < len; i++) {
73+
const key = keys[i]
7274
// elasticsearch will complain for keys without a value
7375
if (object[key] === undefined) {
7476
delete object[key]

lib/Transport.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Transport {
9191
callback = options
9292
options = {}
9393
}
94-
var p = null
94+
let p = null
9595

9696
// promises support
9797
if (callback === undefined) {
@@ -147,9 +147,10 @@ class Transport {
147147
// the size of the stream, we risk to take too much memory.
148148
// Furthermore, copying everytime the stream is very a expensive operation.
149149
const maxRetries = isStream(params.body) || isStream(params.bulkBody)
150-
? 0 : (typeof options.maxRetries === 'number' ? options.maxRetries : this.maxRetries)
150+
? 0
151+
: (typeof options.maxRetries === 'number' ? options.maxRetries : this.maxRetries)
151152
const compression = options.compression !== undefined ? options.compression : this.compression
152-
var request = { abort: noop }
153+
let request = { abort: noop }
153154
const transportReturn = {
154155
then (onFulfilled, onRejected) {
155156
return p.then(onFulfilled, onRejected)
@@ -525,7 +526,7 @@ function defaultNodeFilter (node) {
525526
}
526527

527528
function roundRobinSelector () {
528-
var current = -1
529+
let current = -1
529530
return function _roundRobinSelector (connections) {
530531
if (++current >= connections.length) {
531532
current = 0
@@ -540,8 +541,8 @@ function randomSelector (connections) {
540541
}
541542

542543
function generateRequestId () {
543-
var maxInt = 2147483647
544-
var nextReqId = 0
544+
const maxInt = 2147483647
545+
let nextReqId = 0
545546
return function genReqId (params, options) {
546547
return (nextReqId = (nextReqId + 1) & maxInt)
547548
}

lib/pool/BaseConnectionPool.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class BaseConnectionPool {
128128
*/
129129
empty (callback) {
130130
debug('Emptying the connection pool')
131-
var openConnections = this.size
131+
let openConnections = this.size
132132
this.connections.forEach(connection => {
133133
connection.close(() => {
134134
if (--openConnections === 0) {
@@ -201,7 +201,7 @@ class BaseConnectionPool {
201201
const ids = Object.keys(nodes)
202202
const hosts = []
203203

204-
for (var i = 0, len = ids.length; i < len; i++) {
204+
for (let i = 0, len = ids.length; i < len; i++) {
205205
const node = nodes[ids[i]]
206206
// If there is no protocol in
207207
// the `publish_address` new URL will throw
@@ -210,7 +210,7 @@ class BaseConnectionPool {
210210
// - hostname/ip:port
211211
// if we encounter the second case, we should
212212
// use the hostname instead of the ip
213-
var address = node.http.publish_address
213+
let address = node.http.publish_address
214214
const parts = address.split('/')
215215
// the url is in the form of hostname/ip:port
216216
if (parts.length > 1) {

lib/pool/ConnectionPool.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ConnectionPool extends BaseConnectionPool {
8080
// list a node that no longer exist. The following check verify
8181
// that the connection is still part of the pool before
8282
// marking it as dead.
83-
for (var i = 0; i < this.size; i++) {
83+
for (let i = 0; i < this.size; i++) {
8484
if (this.connections[i].id === id) {
8585
this.dead.push(id)
8686
break
@@ -138,7 +138,7 @@ class ConnectionPool extends BaseConnectionPool {
138138
path: '/',
139139
timeout: this.pingTimeout
140140
}, (err, response) => {
141-
var isAlive = true
141+
let isAlive = true
142142
const statusCode = response !== null ? response.statusCode : 0
143143
if (err != null ||
144144
(statusCode === 502 || statusCode === 503 || statusCode === 504)) {
@@ -170,8 +170,7 @@ class ConnectionPool extends BaseConnectionPool {
170170
isAlive: true,
171171
connection
172172
})
173-
// eslint-disable-next-line standard/no-callback-literal
174-
callback(true, connection)
173+
callback(true, connection) // eslint-disable-line
175174
}
176175
}
177176

@@ -199,7 +198,7 @@ class ConnectionPool extends BaseConnectionPool {
199198

200199
// TODO: can we cache this?
201200
const connections = []
202-
for (var i = 0; i < this.size; i++) {
201+
for (let i = 0; i < this.size; i++) {
203202
const connection = this.connections[i]
204203
if (noAliveConnections || connection.status === Connection.statuses.ALIVE) {
205204
if (filter(connection) === true) {

0 commit comments

Comments
 (0)