Closed trentm closed 1 year ago
I've opened issue nodejs/node#46981 on Node.js to discuss the change,
Since then, node core has effectively fixed this issue in https://github.com/nodejs/node/pull/46989
If you now test with a node v20 nightly after that change, the tests pass:
% NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly nvm install v20.0.0-nightly2023032738e6ac7b44
...
% node --version
v20.0.0-nightly2023032738e6ac7b44
% npm test
...
but either way, I think this transport should change to only pass documented
http.request()
options.
I'll open a PR to do this.
🐛 Bug Report
When using the
HttpConnection
option with the ES client, and using the latest node.js v20 nightly, HTTP communication is broken.https://github.com/nodejs/node/pull/46904 recently (first in v20.0.0-nightly2023030448f99e5f6a nightly Node.js build) introduced a change to the internal
isURL
function that is used byhttp.request()
andhttps.request()
to decide if the first argument is aURL
instance. The new test is if the object includeshref
andorigin
fields. If that is true, then Node'shttp.request()
takes this code path which results in other fields likeheaders
,agent
, etc. being ignored.HttpConnection.buildRequestObject
hits this issue: https://github.com/elastic/elastic-transport-js/blob/64d6fa2c734ac446e15d384c17f61bf5bb755a76/src/connection/HttpConnection.ts#L344-L345(I've opened issue https://github.com/nodejs/node/issues/46981 on Node.js to discuss the change, but either way, I think this transport should change to only pass documented
http.request()
options.)To Reproduce
Expected behavior
When run with the v20.0.0-nightly2023030448f99e5f6a node nightly, note that the custom headers from the ES client do not get through to the server:
But when run with earlier node.js versions, they do:
npm test
also fails with that node version.Your Environment
@elastic/elasticsearch
version: >=8.0.0