Skip to content

Commit

Permalink
Fixed ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Feb 3, 2021
1 parent c890574 commit 592c81b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/plugins/data/server/search/session/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface IScopedSearchSessionsClient<T = unknown> {
options: ISearchOptions
) => Promise<void>;
getSearchIdMapping: (sessionId: string) => Promise<Map<string, string>>;
save: (sessionId: string, attributes: Partial<T>) => Promise<SavedObject<T>>;
save: (sessionId: string, attributes: Partial<T>) => Promise<SavedObject<T> | undefined>;
get: (sessionId: string) => Promise<SavedObject<T>>;
find: (options: Omit<SavedObjectsFindOptions, 'type'>) => Promise<SavedObjectsFindResponse<T>>;
update: (sessionId: string, attributes: Partial<T>) => Promise<SavedObjectsUpdateResponse<T>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
SavedObject,
SavedObjectsFindOptions,
SavedObjectsErrorHelpers,
SavedObjectsUpdateResponse,
} from '../../../../../../src/core/server';
import { IKibanaSearchRequest, ISearchOptions } from '../../../../../../src/plugins/data/common';
import { ISearchSessionService } from '../../../../../../src/plugins/data/server';
Expand Down Expand Up @@ -84,11 +83,7 @@ export class SearchSessionService
sessionId: string,
attributes: Partial<SearchSessionSavedObjectAttributes>,
retry: number = 1
): Promise<
| SavedObjectsUpdateResponse<SearchSessionSavedObjectAttributes>
| SavedObject<SearchSessionSavedObjectAttributes>
| undefined
> => {
): Promise<SavedObject<SearchSessionSavedObjectAttributes> | undefined> => {
const retryOnConflict = async (e: any) => {
this.logger.debug(`Conflict error | ${sessionId}`);
// Randomize sleep to spread updates out in case of conflicts
Expand All @@ -98,7 +93,11 @@ export class SearchSessionService

this.logger.debug(`updateOrCreate | ${sessionId} | ${retry}`);
try {
return await this.update(deps, sessionId, attributes);
return (await this.update(
deps,
sessionId,
attributes
)) as SavedObject<SearchSessionSavedObjectAttributes>;
} catch (e) {
if (SavedObjectsErrorHelpers.isNotFoundError(e)) {
try {
Expand Down Expand Up @@ -251,7 +250,7 @@ export class SearchSessionService
idMapping = { [requestHash]: searchInfo };
}

return this.updateOrCreate(deps, sessionId, { idMapping });
await this.updateOrCreate(deps, sessionId, { idMapping });
};

public async getSearchIdMapping(deps: SearchSessionDependencies, sessionId: string) {
Expand Down

0 comments on commit 592c81b

Please sign in to comment.