Skip to content

Commit

Permalink
[Reporting] fix too_long_frame_exception by passing scroll_id in the …
Browse files Browse the repository at this point in the history
…request body (elastic#102972)

* pass scroll_id in the request body not a param

* update test to match

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
tsullivan and kibanamachine committed Jun 30, 2021
1 parent 3d9d305 commit 8e49ed8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,23 @@ it('uses the scrollId to page all the data', async () => {
const csvResult = await generateCsv.generateData();
expect(csvResult.warnings).toEqual([]);
expect(csvResult.content).toMatchSnapshot();

expect(mockDataClient.search).toHaveBeenCalledTimes(1);
expect(mockDataClient.search).toBeCalledWith(
{ params: { scroll: '30s', size: 500 } },
{ strategy: 'es' }
);

// `scroll` and `clearScroll` must be called with scroll ID in the post body!
expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledTimes(9);
expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledWith({
body: { scroll: '30s', scroll_id: 'awesome-scroll-hero' },
});

expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledTimes(1);
expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledWith({
body: { scroll_id: ['awesome-scroll-hero'] },
});
});

describe('fields from job.searchSource.getFields() (7.12 generated)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ export class CsvGenerator {
this.logger.debug(`executing scroll request`);
const results = (
await this.clients.es.asCurrentUser.scroll({
scroll: scrollSettings.duration,
scroll_id: scrollId,
body: {
scroll: scrollSettings.duration,
scroll_id: scrollId,
},
})
).body as SearchResponse<unknown>;
return results;
Expand Down Expand Up @@ -387,7 +389,7 @@ export class CsvGenerator {
if (scrollId) {
this.logger.debug(`executing clearScroll request`);
try {
await this.clients.es.asCurrentUser.clearScroll({ scroll_id: [scrollId] });
await this.clients.es.asCurrentUser.clearScroll({ body: { scroll_id: [scrollId] } });
} catch (err) {
this.logger.error(err);
}
Expand Down

0 comments on commit 8e49ed8

Please sign in to comment.