Updated abort behavior (#1141)
* Updated abort behavior - Support for aborting a request with the promise api - Aborting a request will cause a RequestAbortedError - Normalized Connection class errors, now every error returned is wrapped by the client errors constructors * Updated test * Updated docs * Updated code generation script * Renamed test * Code coverage * Avoid calling twice transport.request
This commit is contained in:
committed by
GitHub
parent
953a8033ab
commit
27a8e2a9bf
@ -12,7 +12,12 @@ const debug = require('debug')('elasticsearch')
|
||||
const decompressResponse = require('decompress-response')
|
||||
const pump = require('pump')
|
||||
const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/
|
||||
const { TimeoutError, ConfigurationError } = require('./errors')
|
||||
const {
|
||||
ConnectionError,
|
||||
RequestAbortedError,
|
||||
TimeoutError,
|
||||
ConfigurationError
|
||||
} = require('./errors')
|
||||
|
||||
class Connection {
|
||||
constructor (opts = {}) {
|
||||
@ -95,7 +100,7 @@ class Connection {
|
||||
if (ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
callback(err, null)
|
||||
callback(new ConnectionError(err.message), null)
|
||||
}
|
||||
})
|
||||
|
||||
@ -105,6 +110,7 @@ class Connection {
|
||||
if (ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
callback(new RequestAbortedError(), null)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user