-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Allow passing in a signal to abort a cluster client request #37563
Conversation
Pinging @elastic/kibana-platform |
💔 Build Failed |
0ccd052
to
812b644
Compare
err ? reject(err) : resolve(res) | ||
); | ||
if (options.signal) { | ||
options.signal.onabort = () => request.abort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a requirement, but if you want to achieve this without mutating signal
and therefore options
, you can use:
options.signal.addEventListener('abort', () => request.abort());
signal: controller.signal, | ||
}); | ||
|
||
expect(typeof controller.signal.onabort).toBe('function'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of testing the AbortSignal itself, can we call abort
and ensure the call fails?
💔 Build Failed |
812b644
to
40cfb39
Compare
@eliperelman Could you give this another look? |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
* Allow passing in a signal to abort an Elasticsearch request using the cluster client * Go back to using promises (which still return abort method) and update test * Update docs * Explicitly return Promise<any> instead of {}
7.x (7.3.0): 6ca6b1a |
💚 Build Succeeded |
@lukasolson I've started seeing the following error on master and traced it back to here:
There are obviously some auth issues but the thing that makes the server crash is the |
Hmm, the object returned from calling the Elasticsearch JS client should always be returning something with an |
@lukasolson Turns out this is caused by the APM node agent: #52617. |
Resolves #37359.
This PR provides an additional optional option to the
CallAPI
options,signal
, which represents a signal from anAbortController
object. If provided, thencontroller.abort
is invoked, then the request to ES itself will also be aborted.Dev Docs
callWithRequest
now accepts a AbortController signal for aborting requests to Elasticsearch. Example usage: