Compare commits

..

8 Commits

Author SHA1 Message Date
7733eec328 Prepare 7.17.14 (#2294)
* Prepare 7.17.14

* Tweaks to Github action
2024-07-02 11:33:33 -05:00
d614d95b8d Do not retry on timeout by default (#2293)
* Do not retry on timeout by default

* Stop testing on Node.js 12

No longer available on actions/setup-node

* Node.js 14.x is no longer available for testing either

* Fix linter issue

* Update acceptance tests

* Add retryOnTimeout to type defs

* Linter cleanup

* Drop code coverage step from Github action
2024-06-28 13:28:52 -05:00
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
63cd655e79 Bump 7.17.12-canary.1 2023-07-14 11:03:09 -05:00
11a5711409 7.17.12 changelog (#1941) 2023-07-14 10:20:00 -05:00
3f01fafd9e [Backport 7.17] fix: add types to exports (v7.x) (#1930) (#1940)
Co-authored-by: Nicolas Morel <nicolas@morel.io>
2023-07-13 16:12:31 -05:00
cca9a7b212 Bumps 7.17 to 7.17.12 (#1926)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2023-06-29 14:13:50 -05:00
11 changed files with 205 additions and 146 deletions

View File

@ -1,6 +1,6 @@
---
STACK_VERSION:
- "7.17.11-SNAPSHOT"
- "7.17.12-SNAPSHOT"
NODE_JS_VERSION:
- 16

View File

@ -9,36 +9,36 @@ jobs:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Install
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Lint
run: |
npm run lint
- name: Unit test
run: |
npm run test:unit
- name: Unit test
run: |
npm run test:unit
- name: Acceptance test
run: |
npm run test:acceptance
- name: Acceptance test
run: |
npm run test:acceptance
- name: Type Definitions
run: |
npm run test:types
- name: Type Definitions
run: |
npm run test:types
helpers-integration-test:
name: Helpers integration test
@ -46,133 +46,99 @@ jobs:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.16-SNAPSHOT
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.17-SNAPSHOT
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Install
run: |
npm install
- name: Integration test
run: |
npm run test:integration:helpers
- name: Integration test
run: |
npm run test:integration:helpers
bundler-support:
name: Bundler support
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.16-SNAPSHOT
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.17-SNAPSHOT
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v4
with:
node-version: 16.x
- name: Install
run: |
npm install
npm install --prefix test/bundlers/parcel-test
npm install --prefix test/bundlers/rollup-test
npm install --prefix test/bundlers/webpack-test
- name: Install
run: |
npm install
npm install --prefix test/bundlers/parcel-test
npm install --prefix test/bundlers/rollup-test
npm install --prefix test/bundlers/webpack-test
- name: Build
run: |
npm run build --prefix test/bundlers/parcel-test
npm run build --prefix test/bundlers/rollup-test
npm run build --prefix test/bundlers/webpack-test
- name: Build
run: |
npm run build --prefix test/bundlers/parcel-test
npm run build --prefix test/bundlers/rollup-test
npm run build --prefix test/bundlers/webpack-test
- name: Run bundle
run: |
npm start --prefix test/bundlers/parcel-test
npm start --prefix test/bundlers/rollup-test
npm start --prefix test/bundlers/webpack-test
- name: Run bundle
run: |
npm start --prefix test/bundlers/parcel-test
npm start --prefix test/bundlers/rollup-test
npm start --prefix test/bundlers/webpack-test
mock-support:
name: Mock support
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Use Node.js 14.x
uses: actions/setup-node@v4
with:
node-version: 14.x
- name: Install
run: |
npm install
npm install --prefix test/mock
- name: Install
run: |
npm install
npm install --prefix test/mock
- name: Run test
run: |
npm test --prefix test/mock
code-coverage:
name: Code coverage
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Code coverage report
run: |
npm run test:coverage-report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.lcov
fail_ci_if_error: true
- name: Code coverage 100%
run: |
npm run test:coverage-100
- name: Run test
run: |
npm test --prefix test/mock
license:
name: License check
@ -183,17 +149,17 @@ jobs:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: |
npm install
- name: Install
run: |
npm install
- name: License checker
run: |
npm run license-checker
- name: License checker
run: |
npm run license-checker

View File

@ -1,6 +1,45 @@
[[changelog-client]]
== Release notes
[discrete]
=== 7.17.14
[discrete]
==== Fixes
Stops retrying timed-out requests by default.
Re-enabling the old behavior can be done by providing a `retryOnTimeout` option when instantiating the client.
https://github.com/elastic/elasticsearch-js/pull/2293[#2293]
[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
[discrete]
==== Notes
This is the first 7.x release where patch versions of the client will no longer (intentionally) align with patch versions of Elasticsearch. The latest patch release of the client will always be compatible with the corresponding minor release of Elasticsearch.
[discrete]
==== Fixes
[discrete]
===== TypeScript build failure
Fixes a type declaration bug that caused TypeScript builds to fail. https://github.com/elastic/elasticsearch-js/pull/1927[#1927]
[discrete]
===== Add TypeScript type declarations to exports
Adds TypeScript type declarations file to package.json `exports` https://github.com/elastic/elasticsearch-js/pull/1930[#1930]
[discrete]
=== 7.17.11
@ -54,7 +93,6 @@ https://www.elastic.co/guide/en/elasticsearch/reference/7.16/release-notes-7.16.
[discrete]
===== Fixed export field deprecation log https://github.com/elastic/elasticsearch-js/pull/1593#[#1593]
[discrete]
=== 7.15.0
@ -70,7 +108,7 @@ https://www.elastic.co/guide/en/elasticsearch/reference/7.15/release-notes-7.15.
[discrete]
===== Support mapbox content type https://github.com/elastic/elasticsearch-js/pull/1500[#1500]
If you call an API that returns a mapbox conten type, the response body will be a buffer.
If you call an API that returns a mapbox content type, the response body will be a buffer.
[discrete]
===== Support CA fingerprint validation https://github.com/elastic/elasticsearch-js/pull/1499[#1499]

1
lib/Transport.d.ts vendored
View File

@ -49,6 +49,7 @@ interface TransportOptions {
serializer: Serializer;
maxRetries: number;
requestTimeout: number | string;
retryOnTimeout?: boolean;
suggestCompression?: boolean;
compression?: 'gzip';
sniffInterval?: number;

View File

@ -57,6 +57,7 @@ class Transport {
this.serializer = opts.serializer
this.maxRetries = opts.maxRetries
this.requestTimeout = toMs(opts.requestTimeout)
this.retryOnTimeout = opts.retryOnTimeout != null ? opts.retryOnTimeout : false
this.suggestCompression = opts.suggestCompression === true
this.compression = opts.compression || false
this.context = opts.context || null
@ -220,6 +221,13 @@ class Transport {
})
}
// do not retry timeout errors by default
if (err.name === 'TimeoutError' && this.retryOnTimeout !== true) {
err.meta = result
this.emit('response', err, result)
return callback(err, result)
}
// retry logic
if (meta.attempts < maxRetries) {
meta.attempts++

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

@ -6,13 +6,14 @@
"exports": {
".": {
"require": "./index.js",
"import": "./index.mjs"
"import": "./index.mjs",
"types": "./index.d.ts"
},
"./*": "./*.js"
},
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html",
"version": "7.17.11-patch.1",
"versionCanary": "7.17.11-canary.2",
"version": "7.17.14",
"versionCanary": "7.17.14-canary.0",
"keywords": [
"elasticsearch",
"elastic",

View File

@ -88,7 +88,8 @@ test('Connection error', t => {
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnectionError,
maxRetries: 1
maxRetries: 1,
retryOnTimeout: true
})
const order = [
@ -124,18 +125,18 @@ test('Connection error', t => {
})
test('TimeoutError error', t => {
t.plan(10)
t.plan(8)
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnectionTimeout,
maxRetries: 1
maxRetries: 1,
retryOnTimeout: true
})
const order = [
events.SERIALIZATION,
events.REQUEST,
events.REQUEST,
events.RESPONSE
]
@ -170,7 +171,8 @@ test('RequestAbortedError error', t => {
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnectionTimeout,
maxRetries: 1
maxRetries: 1,
retryOnTimeout: true
})
const order = [
@ -221,7 +223,8 @@ test('ResponseError error (no retry)', t => {
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnection,
maxRetries: 1
maxRetries: 1,
retryOnTimeout: true
})
const order = [
@ -373,7 +376,8 @@ test('Deserialization Error', t => {
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnection,
maxRetries: 1
maxRetries: 1,
retryOnTimeout: true
})
const order = [
@ -423,7 +427,11 @@ test('Socket destroyed while reading the body', t => {
}
buildServer(handler, ({ port }, server) => {
const client = new Client({ node: `http://localhost:${port}`, maxRetries: 1 })
const client = new Client({
node: `http://localhost:${port}`,
maxRetries: 1,
retryOnTimeout: true
})
const order = [
events.SERIALIZATION,

View File

@ -680,7 +680,8 @@ test('TimeoutError', t => {
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnectionTimeout,
maxRetries: 0
maxRetries: 0,
retryOnTimeout: true
})
client.on('request', (err, event) => {

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()
})

View File

@ -1025,6 +1025,7 @@ test('Retry mechanism and abort', t => {
serializer: new Serializer(),
maxRetries: 2,
requestTimeout: 100,
retryOnTimeout: true,
sniffInterval: false,
sniffOnStart: false
})
@ -2203,6 +2204,7 @@ test('Compress request', t => {
serializer: new Serializer(),
maxRetries: 3,
requestTimeout: 250,
retryOnTimeout: true,
sniffInterval: false,
sniffOnStart: false
})