Elasticsearch-js: Non-existent timeoutRef.refresh() getting called in Helpers.js

Created on 28 Jul 2020  路  4Comments  路  Source: elastic/elasticsearch-js

馃悰 Bug Report

timeoutRef.refresh is not a function

In Helpers.js, there's a variable called "timeoutRef", which appears to be an integer value coming from a setInterval() call. However, within the bulk and msearch iterate functions, it looks like that variable is being mis-used as an object, eg: timeoutRef.refresh().

I'm not sure what the intent here is, but if it's possible that this variable could contain a "refresh" function, we should be checking for its type first, ie:

typeof timeoutRef.refresh === 'function' && timeoutRef.refresh()

Adding this type check gets me past the bug.

To Reproduce

Steps to reproduce the behavior:

Paste your code here:

const result = await client.helpers.bulk({
  datasource: myDocs,
})```

## Expected behavior
The Helpers module should not throw the error: timeoutRef.refresh is not a function
Paste the results here:

```js
typeof timeoutRef.refresh === 'function' && timeoutRef.refresh()

Your Environment

  • node version: 10
  • @elastic/elasticsearch version: >=7.8.0
  • os: Mac
need info

Most helpful comment

I faced the same issue, but it was due to the JEST execution environment in my case. This error has been resolved by specifying testEnvironment: "node" in jest.config.js. For your information.

All 4 comments

Hello! From the information you have provided, it seems that you are using Node v10, are you sure about that?
timeout.refresh is supported in Node v10, as you can see here, also, the client helpers are tested on Node v10+ and all the test are green 馃

Ah, thanks for the response. I did check my node version and it says 10.15.3. Maybe something else is going on. Closing this issue based on Node JS doc.

I faced the same issue, but it was due to the JEST execution environment in my case. This error has been resolved by specifying testEnvironment: "node" in jest.config.js. For your information.

@ponsea thanks. You made my day. Faced the same thing and didnt even know that jest is running outside of node ;-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lamontadams picture lamontadams  路  4Comments

offlineError picture offlineError  路  4Comments

mojzu picture mojzu  路  4Comments

sjparkinson picture sjparkinson  路  5Comments

loretoparisi picture loretoparisi  路  3Comments