-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Cannot read property 'then' of null" since 7.14.0 #1521
Comments
Hello! It does not look like it's related to #1516. |
Mmmh, in fact, there is a library involved This means that I cannot reproduce the error locally (I dont have an AWS cluster that is accessible from my local machine, and the bug does not happen with my local cluster, which does not not involve AWS auth), but this is functionally equivalent to what we're doing (which is very simple... you know, for search 🙂) import { Client } from '@elastic/elasticsearch';
import connector from 'aws-elasticsearch-connector';
import AWS from 'aws-sdk';
const cached = new Client({
...connector(AWS.config),
nodes: ['...node addresses...'],
});
(async () => {
// some query
await cached.search({});
})(); That said, I'm not sure to see the point of this code when looking at that ... to summarize, you have :
👉 You'll ystematically get the I didnt look into too much details, but that smells weird to me :) |
I managed to reproduce it 🙂 // tslint:disable: no-floating-promises
import { Client, Transport } from '@elastic/elasticsearch';
const delay = () => new Promise(res => setTimeout(res, 10));
const cached = new Client({
nodes: ['http://localhost:9200/'],
// This mimicks aws-elasticsearch-connector
Transport: class extends Transport {
request(params, options = {}, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof callback === 'undefined') {
return delay()
.then(() => super.request(params, options));
}
// Callback support
delay()
.then(() => super.request(params, options, callback));
}
}
});
(async () => {
await cached.search({});
console.log('End');
})(); 👉 The same code works with 7.13.0 |
The code above won't work because you are not returning what |
That is arguable, in my opinion. When using a callback philosophy, you are implicitely asked to call the given callback. But it is not supposed to be mandatory to return something. Else, you are effectively forcing the use of promises, and then I dont see the point of passing a callback as an argument of Anyway, that is how the lib we use (30k weekly downloads) is doing things, and it was working fine until 7.14.0. Since this was working before, this looked like a regression to me :) Moreover, the incriminated code I linked looked sufficiently smelly to me to think that something was going on here. That is kind of a sterile debate, but if your lib supports what you consider to be buggy implementations, then I think most people will expect it to keep supporting them in following minor versions. That said, I'm perfectly happy to be stuck with 7.13.0, my point was only to warn you that this version had potential breaking changes :) |
Hi, still failing in 7.14.1 and 7.15.0 (using the library from pino-elasticsearch). |
Same problem on our end. Version 7.13.0 works perfectly fine. |
There is solution for this? Thanks! |
Closed in #1594. |
💥 Regression Report
Since 7.14.0, we're seing
Cannot read property 'then' of null
errors in@elastic/elasticsearch/lib/Transport.js:167:18
.May be related with #1516 ? (errors are both nullrefs, but not thrown from the same place)
Last working version
Worked up to version: 7.13.0
(fyi we mistakenly did not pin elasticsearch package minor version in our build pipeline, and we've seen that regression in prod, so i'm pretty sure that it has been OK with every version <= 7.13.0 for the past ~2 years)
Stopped working in version: 7.14.0
To Reproduce
I'm not sure... I dont have tried to reproduce it locally.
But call
.search()
? (that is the only thing that our code does, and our prod logs suggest that it was failing systematically)[edit] See snipped here to reproduce
Expected behavior
No errors :)
Your Environment
Elastic Beanstalk running Node 10 (everything is else default)
The text was updated successfully, but these errors were encountered: