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.
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()
@elastic/elasticsearch version: >=7.8.0Hello! 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 ;-)
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.