Compare commits

..

2 Commits

Author SHA1 Message Date
af385f0bac Update changelog for 7.17.13 (#2020) 2023-09-26 11:11:58 -05:00
02c5b8664e Skip adding new nodes that aren't ready yet (#1994) 2023-08-31 12:23:49 -05:00
4 changed files with 44 additions and 2 deletions

View File

@ -1,6 +1,14 @@
[[changelog-client]]
== Release notes
[discrete]
=== 7.17.13
[discrete]
==== Fixes
Fixes a bug where newly-added nodes that don't have HTTP information yet should be skipped during sniffing, to prevent an unexpected `TypeError`. https://github.com/elastic/elasticsearch-js/issues/1230[#1230]
[discrete]
=== 7.17.12

View File

@ -206,6 +206,10 @@ class BaseConnectionPool {
for (let i = 0, len = ids.length; i < len; i++) {
const node = nodes[ids[i]]
// newly-added nodes do not have http assigned yet, so skip
if (node.http === undefined) continue
// If there is no protocol in
// the `publish_address` new URL will throw
// the publish_address can have two forms:

View File

@ -12,8 +12,8 @@
"./*": "./*.js"
},
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html",
"version": "7.17.12",
"versionCanary": "7.17.12-canary.1",
"version": "7.17.13",
"versionCanary": "7.17.13-canary.1",
"keywords": [
"elasticsearch",
"elastic",

View File

@ -313,6 +313,36 @@ test('API', t => {
t.end()
})
t.test('Should skip nodes that do not have an http property yet', t => {
const pool = new BaseConnectionPool({ Connection })
const nodes = {
a1: {
http: {
publish_address: '127.0.0.1:9200'
},
roles: ['master', 'data', 'ingest']
},
a2: {
roles: ['master', 'data', 'ingest']
}
}
t.same(pool.nodesToHost(nodes, 'http:'), [{
url: new URL('http://127.0.0.1:9200'),
id: 'a1',
roles: {
master: true,
data: true,
ingest: true,
ml: false
}
}])
t.equal(pool.nodesToHost(nodes, 'http:').length, 1)
t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200')
t.end()
})
t.end()
})