-
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
Abort cancelled search requests to Elasticsearch #56788
Merged
Merged
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f15f138
Update abort controller library
lukasolson 4d36124
Bootstrap
lukasolson 1943855
Merge branch 'master' into abortController
elasticmachine 491e8bb
Abort when the request is aborted
lukasolson d5d995c
Merge branch 'master' into abortController
lukasolson 8afc936
Merge branch 'abortController' of github.com:lukasolson/kibana into a…
lukasolson 48238d8
Merge branch 'abortController' into abortSearch
lukasolson 0db7257
Add utility and update value suggestions route
lukasolson f376da7
Merge branch 'master' into abortSearch
lukasolson ad5f188
Remove bad merge
lukasolson 48b88c0
Revert switching abort controller libraries
lukasolson 21dd1c8
Revert package.json in lib
lukasolson 16064ff
Merge branch 'revertAbortController' into abortSearch
lukasolson a079c15
Merge branch 'master' into revertAbortController
elasticmachine 0b87a0b
Move to previous abort controller
lukasolson 55d76f3
Merge branch 'master' into abortSearch
lukasolson 8292c1e
Merge branch 'master' into revertAbortController
lukasolson e45bdd6
Merge remote-tracking branch 'origin/revertAbortController' into reve…
lukasolson d3291a8
Merge branch 'master' into revertAbortController
elasticmachine f996a65
Merge branch 'master' into abortSearch
lukasolson 4badc14
Merge branch 'master' into revertAbortController
lukasolson c9352e3
Merge branch 'master' into revertAbortController
lukasolson 100a728
Merge branch 'revertAbortController' into abortSearch
lukasolson 35b1abb
Fix test to use fake timers to run debounced handlers
lukasolson 0db590e
Merge branch 'master' into abortSearch
lukasolson 6cff829
Merge branch 'master' into abortSearch
lukasolson 914d330
Fix loading bar not going away when cancelling
lukasolson fb5ef63
Merge branch 'master' into abortSearch
lukasolson c8c1a95
Merge branch 'master' into abortSearch
lukasolson 365ace1
Merge branch 'master' into abortSearch
elasticmachine f0c2c9c
Merge branch 'master' into abortSearch
elasticmachine 159f5f0
Add test for loading count
lukasolson 5bbae56
Merge remote-tracking branch 'origin/abortSearch' into abortSearch
lukasolson 7f55c43
Merge branch 'master' into abortSearch
lukasolson efa6cf6
Fix test
lukasolson 2ec0d0b
Fix failing test
lukasolson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/plugins/data/server/lib/get_request_aborted_signal.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Subject } from 'rxjs'; | ||
import { getRequestAbortedSignal } from './get_request_aborted_signal'; | ||
|
||
describe('abortableRequestHandler', () => { | ||
jest.useFakeTimers(); | ||
|
||
it('should call abort if disconnected', () => { | ||
const abortedSubject = new Subject<void>(); | ||
const aborted$ = abortedSubject.asObservable(); | ||
const onAborted = jest.fn(); | ||
|
||
const signal = getRequestAbortedSignal(aborted$); | ||
signal.addEventListener('abort', onAborted); | ||
|
||
// Shouldn't be aborted or call onAborted prior to disconnecting | ||
expect(signal.aborted).toBe(false); | ||
expect(onAborted).not.toBeCalled(); | ||
|
||
abortedSubject.next(); | ||
jest.runAllTimers(); | ||
|
||
// Should be aborted and call onAborted after disconnecting | ||
expect(signal.aborted).toBe(true); | ||
expect(onAborted).toBeCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Observable } from 'rxjs'; | ||
// @ts-ignore not typed | ||
import { AbortController } from 'abortcontroller-polyfill/dist/cjs-ponyfill'; | ||
|
||
/** | ||
* A simple utility function that returns an `AbortSignal` corresponding to an `AbortController` | ||
* which aborts when the given request is aborted. | ||
* @param aborted$ The observable of abort events (usually `request.events.aborted$`) | ||
*/ | ||
export function getRequestAbortedSignal(aborted$: Observable<void>): AbortSignal { | ||
const controller = new AbortController(); | ||
aborted$.subscribe(() => controller.abort()); | ||
return controller.signal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { getRequestAbortedSignal } from './get_request_aborted_signal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Curious, if this is a bug fix and if there should be a test case for this?
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.
Yes it is and yes there should be.
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.
Added in 159f5f0.