-
Notifications
You must be signed in to change notification settings - Fork 726
Description
π Bug Report
In v7.14.0 a request that is aborted quickly (while the productCheck()
request is still going) properly results in the request callback (or promise resolution) including the RequestAbortedError
instance. However, the emitted Client "response" event does not include that RequestAbortedError
instance.
This is a challenge for https://github.com/elastic/apm-agent-nodejs which is attempting to use the "request" and "response" Client events for APM tracing. This means APM will not report an error for a quick abort.
To Reproduce
- Save this as "esfoo.js"
const { Client } = require('@elastic/elasticsearch')
var client = new Client({
node: 'http://localhost:9200',
auth: { username: 'admin', password: 'changeme' }
})
client.on('response', function (err, event) {
console.log('"response" event: err=', err && err.name)
})
var req = client.search(
{ body: { size: 1 } },
function (err, _result) {
console.log('callback: err:', err && err.name)
}
)
setImmediate(function () {
req.abort()
})
with earlier versions:
% npm ls @elastic/elasticsearch
elastic-apm-node@3.19.0 /Users/trentm/el/apm-agent-nodejs8
βββ @elastic/elasticsearch@7.13.0
% node esfoo.js
"response" event: err= RequestAbortedError
callback: err: RequestAbortedError
with v7.14.0:
% npm ls @elastic/elasticsearch
elastic-apm-node@3.19.0 /Users/trentm/el/apm-agent-nodejs8
βββ @elastic/elasticsearch@7.14.0
% node esfoo.js
"response" event: err= null
callback: err: RequestAbortedError
Expected behavior
I realize the "response" event being sent here is for the Transport.prototype.request
for the productCheck()
so it might not be complete straightforward. Could the req.abort()
be passed through to the productCheck request if it is ongoing?
Your Environment
- node version: v12.22.1
- os: Mac